Moving From WordPress to Hugo

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:

  1. WordPress is lovely, but it’s the only reason I have PHP running on my web server
  2. WordPress doesn’t have a fantastic track record regarding security, though this is mostly down to poorly written plugins
  3. I very rarely update my site, so running a full-on content management system with all its bells and whistles seems a tad overkill
  4. Using a static site generator lets me play with some new things
  5. 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
  6. In theory it’s much faster and more secure to have a statically built website
  7. A lot of people I respect are using static site generators

There are a few options for static site generators, including:

  • Hugo - Written in Golang
  • Jekyll - Written in Ruby
  • Ghost - Built on Node.js
  • And lots of others…

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:

  1. Followed the Hugo Quickstart Guide to get to know the system
  2. Exported my WordPress posts and pages using the exporter built into WordPress
  3. Used the Exitwp Python script to convert the exported XML into Markdown files
  4. 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…
  5. Decided to use the Casper theme
  6. Created a private git repository to use for my actual website
  7. Created a brand new empty Hugo site scaffold and added it to my git repository
  8. Configured Hugo to use the Casper theme, and imported my various Markdown files (while doing git commit on a neurotically frequent basis)
  9. Once happy, performed a hugo build to create the public static code output
  10. Moved my old site files out of the way
  11. Copied the new Hugo built files onto my server, and voila!