Reviving My Blog and Embracing Serverless

Posted on January 18, 2023 in blog • 3 min read

Hello again, world! For the last several months, this blog was offline simply because I neglected to renew the VPS that I was hosting it on, and I didn't bother to rectify the situation since this blog was always a hobby project to begin with. I finally scrounged up some spare time over the winter holidays to do just that.

Several years back I migrated from Wordpress to Pelican for a variety of reasons, one of them being the reduced maintenance burden at a much lower cost. At the time I thought hosting a static blog on my own self-maintained VPS/cloud server would be sufficiently low maintenance, but that was back when I was still in university with ample time in my hands, and back when simple sysadmin tasks were a learning opportunity for me. I no longer enjoy self-inflicted hobbyist sysadmin work and my dayjob as a software engineer has me carefully rationing my spare time.

"Serverless" and "JAMStack" at this point may have become overly marketed buzzwords (or so goes the sentiment on Hacker News), but the core idea of taking the maintenance burden of self-hosting / paying for hosting, and offloading that to a CDN of my choice, definitely appeals to me now.

With all that said, I've migrated my Pelican-based static site to Cloudflare Pages, mostly because I already use Cloudflare DNS and Pages was easy to setup and use, with no need to involve yet another vendor. Github Pages was something I also briefly considered, but Github Pages doesn't support non-Jekyll static site generators, and using Pages to build my site for me gives me a free CI pipeline and one less thing to maintain (I can get straight to updating my blog without having to rebuild my dev environment if I'm not in front of my PC). Netlify is also another contender of course, as are other CDNs and vendors, but then I have to deal with the friction of a platform/product that I don't already use.

If you end up deploying your Pelican-based blog to Cloudflare Pages, Cloudflare has pretty good documentation to get you up and running. One thing I would point out here is that pelican-quickstart by default will generate two different configuration files, for dev-specific and general settings, and for production-specific settings. If you enter pelican content as the suggested build command in Cloudflare Pages, pelican is only going to read your and ignore your prod-specific settings - so if you're wondering why e.g. your Disqus comments aren't appearing, or worse, everything on your deployed site links to localhost:8000, that would be why. Make sure you call pelican content -s to have pelican build your site with the desired settings. Also be aware of what platform limits are in place for Cloudflare Pages.

My end goal is to make this blog as easy to maintain as possible, while doing my best to avoid vendor lock-in. With that in mind, I've tried to avoid depending on too many Cloudflare-specific features and functionality, but some of it was inevitable:

  • SSL (to be fair this comes out of the box with no further configuration)
  • www -> apex redirects with Cloudflare bulk redirects (instead of e.g. apache mod_rewrite), along with apex CNAME flattening
  • 404 error handling

All in all, I'm happy to have embraced serverless for my personal blog. I can make changes simply by pushing to Github and have them live in less than a minute. Hosting my blog on a CDN guarantees it'll have better uptime and reliability than I could ever hope to achieve (I'm pretty sure I lose out here just by having to restart apache to apply patches, on my server). And, of course, there is practically zero maintenance overhead for me to deal with now. The only way for my site to go offline now is if I forget to renew my domain (which will not happen because that would take my email with it as well, and that is something I would definitely notice).