← notes

A build script that renders PHP to static HTML

Oct 18, 2019

A personal site where PHP is the template language and what gets deployed is static HTML.

Every page exists twice, about.php and about.html, articles.php and articles.html, contact.php and contact.html, with build.sh running the PHP and writing the HTML.

This is a legitimate pattern almost nobody describes. PHP has includes and variables and is on every machine, which is all a template language needs. Running it once at build time gives shared headers and footers without adopting a generator, learning its conventions, or accepting its opinions about content structure. The deployed site is static files with no runtime dependency, which is the cheapest and most durable thing to host.

The hazard is that both files are committed and nothing marks which is source. Editing about.html works, looks correct, and is silently discarded on the next build. A generator solves that by putting sources and output in separate directories with the output ignored, and that is the improvement worth stealing without adopting the rest.

It ran for about five years. email-assets/ holds MailChimp-ready HTML, which is its own reminder that email templates share nothing with the site advertising them.