A tale of serving static blog contents
I remember reading from somewhere (probably Twitter) that running WordPress is an open invitation for hackers to take control of your server. This blog was running on WordPress since 2010, and many things have changed over the years. I am no longer writing blogs furiously (like one blog post per day circa 2010). In fact my last blog post was in Feb 2019, more than a year ago. I also no longer need any advanced feature of WordPress anymore like users sign up or comments (both are open invitation to spam).
That’s why I decided to convert my blog from WordPress to static contents, effectively getting rid of the PHP and MySQL part from my LEMP stack. My blog is now auto-generated from Markdown, and Nginx is great at serving static content. I can easily host it on a free Google Cloud instance.
The first step is to export my blog posts from WordPress into Markdown format. I’ve been eyeing a couple of solutions like wp2md or wordpress-to-markdown but finally settled on Hugo. Hugo is written in Go (a big plus), has great support for exporting content from WordPress, including images and attachments (wordpress-to-hugo-exporter), fast and very lightweight (building my whole blog takes about 500ms).
The next step is to decide where to host my blog posts. Because my blog is now purely static contents, GitHub Pages or GitLab Pages are natural choices. However both of them do not support HSTS at the moment (issues on GitHub and GitLab) so they’re no go. Finally I settled on a free Google Cloud f1-micro instance. It’s a full-fledged VPS so I can install Nginx, setup Let’s Encrypt certbot and stuff. It’s been working great so far. The only limitation of this setup is that the free Google f1-micro instance comes with only 1GB network egress compared to 1TB of Amazon or DigitalOcean, so the overage charge might exceed what I’m paying on DigitalOcean at the moment. I guess I’ll know by the end of this month.
One thing I missed is not having PHP on my server, but the last time I wrote PHP code must be years ago, when MVC started to gain traction, so it’s not that bad honestly.