You may use any static site generator in conjunction with Tome by reading exporting JSON directly. See tome-gatsby for an example of a Gatsby integration.
If you want to use Drupal to generate HTML, Tome ships with a static site generator that uses Drupal's internal request handling and concurrency to ensure that pages are exported as quickly as possible.
The static site generation flow works like:
- The "drush tome:static" command is ran.
- The "tome.static" service collects all paths known to Drupal. Currently this is a combination of all routes that do not use parameters, and all entity "canonical" paths (and the paths of their translations). If the site uses URL language negotiation, each configured language prefix is also collected. Only entities/routes that are accessible to anonymous are exported.
- The "cache.tome_static" service removes all paths that already cached and in the static build. The cache uses core cache tags to determine cacheability of paths.
- Paths are exported using a user-configurable concurrency, which defaults to five. This means that five paths will be processed by Drupal at a time.
- For each path, the script first checks if the path is a static file that can be immediately copied. This is common for pre-generated files in the files directory.
- If the path isn't a static file, a new process is invoked and Drupal handles the request. This is done using the "http.kernel" service. If a response with the status code 200 is returned, the content of that response is saved to the filesystem.
- If the response was HTML, that HTMl is parsed and assets are collected. The currently recognized assets are pager links (to support Views pagers), images, responsive images (using srcset), stylesheets, scripts, and favicons.
- If the response was CSS, URLs within "url(...)" are parsed as assets.
- All collected asset paths are then returned to the parent process, which exports them starting at step 3.
- Steps 3-8 repeat until there are no more assets to be exported.