Notes on static sites
I moved this site from a database-backed blog to a static build a few months ago. The motivation was not performance — the old site was plenty fast for the traffic it got. The motivation was that I wanted the archive to survive me losing interest in maintaining it.
A directory of HTML files does not need patching. It does not need a PHP upgrade, a database migration, or a security advisory every other month. It just sits there and serves bytes. That property is worth a lot when the thing you are running is essentially an archive of your own writing.
The build is the interesting part
Static generators trade runtime complexity for build complexity. That is a good trade for a blog, but it is not free — you now have a build step that can break, and the breakage is often silent.
The rule I settled on: the build must be reproducible from the repository alone. No global state, no “it works on my machine”, no manually copying assets in afterwards. If a fresh clone cannot produce the same output with one command, the setup is not done.
# the entire build
hugo --minify --gc
Two flags are doing real work there. --minify shaves the obvious whitespace;
--gc cleans up unused cache entries so the output directory does not slowly
accumulate stale pages that nobody links to anymore but which still answer 200.
Things that bit me
Stale files in the output directory. Some generators do not delete output for pages that no longer exist. Rename a post and you get both versions published. The fix is to build into an empty directory, always — never build incrementally into the same place and assume it is clean.
Absolute URLs in content. If the site is ever served from a different host or path, every hardcoded absolute URL becomes a dead link. Relative paths everywhere cost nothing and remove an entire class of failure.
Feeds and sitemaps quietly embedding the base URL. These files are generated, so they are easy to forget, and they will happily publish a domain you did not intend. Worth grepping the output for your base URL before deploying.
Serving it
The serving side is almost boringly simple, which is the point. A file server, a directory, and a 404 page. No rewrite rules that need debugging, no cache invalidation to think about, no application to keep alive.
The one thing worth getting right is the 404 page. It should be self-contained — if it links to a stylesheet with a relative path, it will render as unstyled text when served from a nested URL. Inline the styles or use root-absolute paths and it will look correct from anywhere.
Would I do it again
Yes, and I have. Every small site I have moved to a static build has needed less attention afterwards, not more. The failure mode of a static site is that it keeps working when you stop looking at it, which is exactly what I want from something whose only job is to be read.