Type to search. Arrow keys to move, Enter to open, Esc to close.

All technologies

Static site generation

Building the HTML of websites from templates and data at build time, so the server only serves finished files. Here extended to several domains from one source.

Project requirement

Keep several small websites with a shared look on shared Apache hosting, without a server-side runtime.

Technical question

How can shared parts live in one place while each site can still override them, and links between the sites keep working locally and online?

Validation

Three sample sites build from one source with shared and per-site layers; tests cover links, assets, overrides and the generated files.

Decision

A small Python and Jinja2 build with a shared layer, per-site overrides on the same path, and generated server configuration.

Generated per site: sitemap.xml, robots.txt, llms.txt and an Apache .htaccess with https redirects, old-URL redirects, HSTS and cache headers.

HSTS starts with a short max-age and is raised only after https has been stable, because it is hard to undo.

Implementations by language

Python

A Python build reads the sites from TOML, renders Jinja2 templates per domain and syncs the result into one output folder per site.

  • The template loader searches the site's pages first, then the shared templates, so every page extends one shared layout.
  • Template globals link(domain, path) and asset(path) give root-relative or absolute links and content-hashed CSS/JS URLs.
  • StrictUndefined and HTML autoescaping make typos and unescaped text fail or stay safe at build time.

Used by projects

Related research