Ugly picture of the eleventy possum

Going static

25 January 2021

Over the last week or so I've migrated this website and blog from a custom PHP CMS I built to an Eleventy build hosted on an Azure storage container.

So why did I go static?

I did get partly inspired by this Eric Meyer post about going static. He's mainly addressing government agencies in a call for them to improve their web services to provide accessible information in the time of Covid 19 - So not a whole lot to do with my little developer blog! But it underlines some of the benefits of static sites. Here are the main reasons I went static:

Why go static? Performance #

Moving from old-school PHP shared hosting to static means you get the benefits of the CDN (content delivery network).

A CDN makes copies of your site and distributes them to servers around the globe. It means that people visiting your site pull the information from an closer source regardless of where they are in the world, whereas my old hosting company were based in Sydney. CDNs also use caching to increase performance.

WordPress sites can have CDN level caching if you know what you're doing and pay more for the set up, but static sites have CDN hosting almost as the default.

The other reason the performance is better is that you don't have to boot up a PHP instance and grab data from a database on every request. PHP is reasonably fast, but these steps definitely take time.

Why go static? Money #

This is one that doesn't get talked about as much as I'd expect. Maybe because everyone on the tech industry is so damn rich, but static hosting can be cheaper than PHP hosting. So far the hosting has cost me nothing with Azure. But after a year they start charging by the amount of data they send over the wire.

The thing is, this site would have to be visited hundreds of thousands of times before the costs would match what I've been paying to run a PHP server and MySQL on shared hosting. Another benefit is the free SSL I get from Azure which would've cost about $100 a year from traditional hosting.

Why go static? Deployment and developer experience #

With the previous PHP host, I needed to use FTP to upload my site. Most of the time this was okay but there were times that I forgot to upload a file and it caused the entire site to crash. I also made a simple misspelling in my database credentials once and I think it took me two hours to find and fix it.

When setting up a dev server for my PHP site, it would take a while to set up which folder to point my dev environment, and I still didn't get any live reload.

Now I can develop with Eleventy using the built-in dev server. Then when I've finished, commit those changes and push to github. Then (and this is the cool part) a github action will automatically push the site up to Azure using the Azure cli. I used this guide from the Azure docs to get it done. Although for some reason it does send me a warning every time - even though it seems to work.

This is still a far better experience than the PHP deployment experience i had.

I would definitely recommend going static for a simple blog site and I'm excited to keep using Eleventy as a way to build performance websites.

Back to blog