For a while now I’ve been toying with the idea of switching my site from WordPress to a static site generator. There are a few reasons why I’ve been considering it:
- WordPress is lovely, but it’s the only reason I have PHP running on my web server
- WordPress doesn’t have a fantastic track record regarding security, though this is mostly down to poorly written plugins
- I very rarely update my site, so running a full-on content management system with all its bells and whistles seems a tad overkill
- Using a static site generator lets me play with some new things
- I like the concept of using version control so I can treat the site as code, and undo changes when I go down a rabbit hole
- In theory it’s much faster and more secure to have a statically built website
- A lot of people I respect are using static site generators
There are a few options for static site generators, including:
I’ve personally gone with Hugo, though the choice seems to be very much down to personal preference at this point. All the generators support Markdown, they all allow you to customise the theme of your site, and all seem to have a relatively active developer community around them.
Here’s what I did to move from WordPress to Hugo:
- Followed the Hugo Quickstart Guide to get to know the system
- Exported my WordPress posts and pages using the exporter built into WordPress
- Used the Exitwp Python script to convert the exported XML into Markdown files
- Used
hugo server -D
to monitor what happened when I made changes, such as: * Copying the exported Markdown into my Quickstart Hugo site * Playing around with various options and themes * Spending a week trying a lot of themes… - Decided to use the Casper theme
- Created a private git repository to use for my actual website
- Created a brand new empty Hugo site scaffold and added it to my git repository
- Configured Hugo to use the Casper theme, and imported my various Markdown files (while doing
git commit
on a neurotically frequent basis) - Once happy, performed a
hugo
build to create thepublic
static code output - Moved my old site files out of the way
- Copied the new Hugo built files onto my server, and voila!