How to migrate from WordPress to a Static Blog on Amazon S3, Google Cloud or Azure

I've been blogging for over 20 years and for much of that time I've been a WordPress user, it's one of the simplest and most flexible CMS platforms there is, and it's accessible to everyone.  I love WordPress specifically because it's easy to use, produces good looking sites and it's free.  

So, why look for alternatives?  

The big challenge hosting a WordPress site is that it comes with a certain amount of stress, a cold constant dread in fact.  Why?  Because WordPress is so popular it gets a lot of attention from attackers.  The attackers then build automated attacks that can quickly exploit vulnerabilities found in plugins, themes, or WordPress itself.  I've had sites attacked a bunch of times over the years, and it's just draining.  Fixing vulnerabilities, restoring sites only to find the same Advanced Persistent Douchebag exploiting a future vulnerability and leaving a handy text file saying how it's really a service letting me know about the issue.  It's tiring, and not really what I want to spend my life doing.  

Over the course of 2020, Wordfence blocked more than 90 billion malicious logins... at a rate of 2,800 attacks per second targeting WordPress.

WordPress themselves have done a great job of trying to mitigate the risks with automatic updates, etc. but honestly, keeping up with it just isn't something I want to focus my time on.  The easy way to mitigate the risk is to use a hosted service like WordPress.com, but I'm already paying for web hosting for other reasons so that just adds cost.  

What I really wanted to do is keep everything simple, removing the fear of hosting a dynamic website by publishing static web pages to an Amazon S3 bucket and whacking a domain name over the top.  Amazon S3 is a basic storage product that can also be configured to serve web pages, similar offerings are also available on Google Cloud and Azure.  It’s a particularly attractive option for website hosting as it’s ridiculously cheap and serving static content means that there’s virtually no security risk.  Even if someone managed to get into my S3 bucket (very unlikely given the $gazillions Amazon put into security), the only thing they’d get access to would be the publicly available site.  

What is a Static Site Generator?  

It's the thing I hoped would exist when I googled it, the thing I found myself somewhat disappointed in, until now.  The disappointment came from learning that most of the popular Static Site Generators create blogs or websites of varying complexity based on text files containing markup and require some local install of node.js, Ruby or something else.  

Top players in this technical realm include: Hugo, Pelican, Eleventy, Nicola and Jekyll.  

To me it's a classic example of "by developers, for developers", this feels convenient if you live in a world where resolving your own build dependencies is the norm, but it's not for most people.  Sure, I'm a technical guy but if I want to write a blog post the last thing I want to do is spend time faffing around with text files and scripts.  I want to write some good content, make a decent graphic on Canva and get it posted.  

After the initial disappointment passed I returned to my search expecting to find the least fiddly of the options but was pleasantly surprised to find Publii.

Publii is Amazing

It's an open source desktop app that acts as a Content Management System, generates static sites and publishes them to your host.  The idea of a desktop app did put me off at first since fat client is a bit old school, but when I took a step back and thought about simplicity I realised that a desktop app is the right solution.  I can be 100% offline and still write content, and you can sync the files via DropBox or OneDrive so that multiple machines can author the site.  

It's a beautifully modern app that's easy to use and is available for Mac, Windows and Linux.  They're are themes, three types of post editor and pre-built connectors for Amazon S3, Google Cloud, GitHub Pages, GitLab Pages and others via manual connection.  I’ve found it as easy to use as WordPress and almost as flexible layout-wise but generally I’m so much happier with the idea of static content that I’m more than willing to put up with a few constraints.  

How to Migrate from Wordpress to Publii

After setting up Publii and configuring your site storage (great docs can be found here) the process I followed was:  

  1. In WordPress Admin go to Tools --> Export
  2. Choose All Content and Download Export File, this will provide an XML download that is referred to generally as a “WXR file”
  3. In Publii, to to Tools and select WP Importer
  4. Import the WXR XML file you downloaded. 
  5. Review the options to make sure you’re happy to import everything. 
  6. Hit the Import data button and wait as the file is processed.  
  7. Go to Tools --> Regenerate thumbnails (I’m not 100% certain it’s needed)
  8. Hit “Sync your Website” and the whole lot was uploaded to the S3 bucket.  

It may take a little while to complete based on the size of the site but it worked very quickly for me and the site was pretty-much instantly available.  The other bonus is that as I shifted my old URL to the new site Publii retains the same page stubs as Wordpress so the URLs are the same and I don’t have to worry about adding redirects here there and everywhere.  

I did have some images that didn’t come across correctly but that may be to do with issues on my WordPress site (my hosting provider was being awkward so I’d restored it to another site on a different URL which may have confused matters).  One thing I did spot with Publii is that as you play with themes, layouts, etc. it’s often best to regenerate your thumbnails before uploading.  

Lastly, if you are using Amazon S3 you can have people access the site directly but you’ll most likely (a) want to put your own domain over it, and (b) want to secure access to it so you will likely want to implement CloudFront in AWS or, as I chose to do, put Cloudflare over the top to provide an extra layer of security and caching.  Much of Cloudflare’s security credentials here are rendered pointless by the underlying content being such low risk now, but the level of control and customisation you get from Cloudflare is outstanding so it’d still be my recommendation.  

In Conclusion

Whilst it’s early days for me and Publii, I successfully migrated my blog from Wordpress to a Static Amazon S3 hosted site - all in just a few hours and I’m really happy with.  I've now got peace of mind and I don't have to worry about some hacker attacking the site.