Skip to content

Drupal as static site generator with Tome

Posted on:September 14, 2023 at 10:25 PM

Tome: A Drupal module that provides us with a static site generator.

Before we begin, I want to talk a bit about what a static site generator is, as I don’t assume that everyone in Drupal knows what it is. In general, a static site generator is something that takes a structured source file, like Markdown, processes it in some way, and you get static HTML as a result. If you’ve been in web development for more than 10 years, you might think we’re done with HTML, right? In fact, we’ve stopped writing it almost by hand. Static site generators take us back to a time when the final result of your website is completely static, i.e., an HTML file. You don’t have a runtime; that’s basically the idea behind it. You’ll never write HTML; you’ll be editing a nicely structured source file.

As for the benefits of using a static site generator, and this doesn’t apply only to “Tome” but to all static site generators:

On the flip side, not everything that glitters is gold. For example, if you have authenticated users, I’m not sure static sites are suitable for you. I know it’s possible to use them together, but you might want to use a traditional Drupal stack if you really like editing in production and seeing your changes instantly. So, a traditional stack might be suitable for you. But the main question, and this is posed in a way that sounds negative but might not be, do you need PHP and MySQL waiting for requests if all your site does is generate requests that can be cached on the CDN? Why not generate all your pages in advance? That’s the main question with static site generators, and it’s okay; you may really need traditional hosting. I’m not trying to say you don’t need it or that “Tome” is better than any other way to host Drupal; it’s just an alternative.

Let’s talk a bit more about Tome.

Tome generates HTML and static content. This is a new concept in Drupal. It means that everything from your YAML configuration files to your codebase and your content is stored as files in version control, and you only use Drupal locally. It’s more like an application you open on your computer to edit content than a server you have to log into. This is a very important concept. The short version is that Drupal is built from files, synced with files, and at the end of your local session, you get static HTML to place somewhere, and then you can shut it down. You don’t need to pay for Drupal hosting; it’s not persistent. You can use Git for everything. There are many interesting benefits to this.

This is just an introduction to Tome. You can use it in different ways depending on your needs. You can use “Tome static” and “Tome sync” separately if you only want the static HTML part or if you only want to store content in Git. There are many options.

More info: