From WordPress to a Static Site
Background
This blog has run on WordPress since 2011. For most of that time it has lived on a server I maintain, alongside a handful of other WordPress sites. That’s a lot of machinery for 23 posts that rarely change: PHP, a MySQL database, a theme framework, plugins, and a never-ending stream of updates. I started moving those sites off the server, and this one was first in line.
Why Static
I don’t need comments (the last one came in 2019), a search box, or a contact form (mine had been quietly broken for who knows how long). I do want writing a post to be easy. With a static site generator, a post is a Markdown file in a Git repository. I can write it in emacs. Of course.
How I Did It
I went with Hugo and Cloudflare Pages.
- Export. The WordPress REST API made it easy to pull every post, page, category, tag, and comment into Hugo content files.
- Same URLs. Posts keep their old
/YYYY/MM/DD/slug/addresses, so existing links still work. The old feed and pagination URLs redirect to their new equivalents. - No theme. One small template, a few lines of CSS, and no JavaScript.
- Comments. The old comments are preserved as plain text. If you want to reach me, email me.
- DNS. I moved the domain’s DNS to Cloudflare. The one scary part was email, so I compared every record between the old and new DNS before flipping the switch. Mail kept flowing.
Now when I push to Git, Cloudflare builds and deploys the site in about 20 seconds. Done!
Is It Faster?
Yes. I measured four pages before and after the switch: five requests each, from my desktop, each on a fresh connection.
| Page | WordPress | Static | HTML size |
|---|---|---|---|
| Home | 709 ms | 289 ms | 58 KB → 4 KB |
| A post | 490 ms | 297 ms | 33 KB → 2 KB |
| A tag listing | 639 ms | 307 ms | 51 KB → 2 KB |
| About | 491 ms | 314 ms | 28 KB → 1 KB |
Pages load 35–60% faster, and the HTML is 90–97% smaller. And that’s just the HTML: the WordPress pages also pulled in six JavaScript and CSS files plus web fonts. The new pages load nothing else.
Conclusion
In brief, the site is faster, simpler, and free to host, and there’s nothing left to patch. I should have done this years ago. Maybe now I’ll even write more often.