Add a static generation tool to core

Created on 30 August 2021, over 3 years ago
Updated 2 January 2024, over 1 year ago

Problem/Motivation

Drupal is less relevant today than it used to be for a large part of Drupal's historic user-base (read hobbyists). Total cost of ownership is pretty high and nowdays people prefer exploring the wild JS ecosystem of tools to make and publish websites.

A trend that came back is static websites. Another trend is decoupled websites. The intersections of both topics surfaced some fundamental problems with statically rendering a website: how to avoid a full site render when a single piece of content has changed.

Last year several frameworks made big announcements around incremental builds: gatsby, nextjs, and probably others.

This has been a solved problem in Drupal 8, and solved in a generic way, unlike gatsby/wordpress integration, thanks to cache-tags . The original use case was to make sure content was properly updated in CDNs , and a static version can be seen as a DIY CDN :)

For several years the awesome Tome module has been available to export a Drupal site into a static version, using incremental build by default. I've managed a team that implemented Tome on a high traffic website, it uses redirections, about 23 languages, and by now thousands of pages.

To recap:

  • Drupal has a technological advantage: I don't think other CMS can come close to Drupal about tracking content in caches in a generic way (haven't seen anything from wordpress, joomla, or typo3 other than TTL & per-url or per-block cache, without the content dependency information)
  • Static sites drastically reduce the total cost of ownership (what security updates? don't need to update as often, even if you still should!)
  • Static site hosting is cheap nowdays, at least much cheaper than a production ready Drupal server(s)
  • For the developer audience static sites are as popular, if not more, than decoupled websites (just look at the number of static generators :p)
  • People who do decoupled to have a static site won't need to add another tech layer and can just use vanilla Drupal

Proposed resolution

Provide a way for Drupal core to output a static site and provide guidance/support for common use cases:

  • Redirects
  • localized 404/403 pages
  • Provide a true opinionated implementation of progressive decoupling to make static + authenticated a possibility
  • Possibly (just an idea, not the focus of this issue) Provide a supported way to expose general purpose API (to handle form submits, comments, search, etc.)

Some things that could be done to make this easier:

  • Make aggregated assets URLs more predictable (to avoid having to crawl the generated HTML)
  • Image style generation (on upload, instead of on demand for example)
  • To some extend, an API endpoint that can be exposed for form submission (contact module, webforms, etc.)

The last point is not the core of this proposal, only a nice side-effect, and could be a starting point to re implement some of Drupal features in a different stack (go? rust? js? java :p?) or at least have a server that can handle websockets better to unlock some more advanced features.

The core idea here is to make use of our incredible cache-tags implementation to leapfrog the other CMSs in the static generation space.

Remaining tasks

API changes

The hard part of tracking content is all already done with cache tags!

Feature request
Status

Active

Component

Idea

Created by

🇫🇷France nod_ Lille

Live updates comments and jobs are added and updated live.
  • Needs product manager review

    It is used to alert the product manager core committer(s) that an issue represents a significant new feature, UI change, or change to the "user experience" of Drupal, and their signoff is needed. If an issue significantly affects the usability of Drupal, use Needs usability review instead (see the governance policy draft for more information).

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany flauschi.hakigo

    I would be interested in contributing to this idea.

    Especially in projects of the public hand, this would be a game changer. Often, there is a security requirement that the content editors only work in a secured environment, e.g., a VPN, and the outside world only sees a static version.

    So, how can I help?

  • 🇺🇸United States rlnorthcutt Austin, TX

    Yes - this would be a good thing to make progress on. As stated, there is a definite need and core contains much of what is needed.

    I recently came across "FrankenPHP" which has a method for compiling a PHP app to a stand alone binary. So - consider that the Drupal instance is only needed for creation and editing, with the static output going to S3, GH pages, GL pages, etc.

    If set up properly, then each author could simply add their content as a MR to the repo, and manage any edits or new content with Git. The DA could offer a free website to all users with GL Pages, and could offer a low cost solution for non-profits or smaller orgs. That would not only spread Drupal, but also help the DA generate a bit more funding.

  • 🇮🇹Italy kopeboy Milan

    Yeah, one could work locally with DDEV or with a binary (both desktop or in the browser, see https://mglaman.dev/blog/running-drupal-edge-webassembly) and commit the changes to some repository or data availability protocol in general (Github, traditional or decentralized hosting).

  • 🇳🇿New Zealand quietone

    The Ideas project is being deprecated. This issue is moved to the Drupal project. Check that the selected component is correct. Also, add the relevant tags, especially any 'needs manager review' tags.

Production build 0.71.5 2024