I’ve been using WordPress for many years. I started using it ~2008 to host the Cocos2d blog. And then I used it for my personal blogs.

But I’ve been wanting to switch to a static site generator for a while. And I finally did it. I’m now using Hugo hosted in GitHub Pages. And this is how I did it:

Export your files

  1. Log in to your WordPress site as “admin”
  2. Tools -> Export
  3. Export “content”
    • Optionally export “media library” as well, but won’t be used in this guide.
  4. Unzip it

Download and run wp2hugo

There are different ways to migrate to Hugo. The one that I tried was wp2hugo, and it worked reasonably well.

  1. Download wp2hugo

  2. Run wp2hugo with your exported “content”:

    # Valid for Linux / macOS. Might work for Windows.
    cd ${EXPORTED_CONTENT}
    wp2hugo --source wordpress-export.xml --download-media --output /tmp
    
  3. Test the generated files

    # In /tmp/ you will find a "generated" folder.
    cd /tmp/generated-...
    
    # Run hugo
    hugo server
    

Try it locally by opening this URL http://localhost:1313/

Fix possible convertion issues

A few things that failed and that I had to fix them one by one manually:

  • Some “unrecognized character in shortcode action”
  • HTML Tables were broken.
  • Image [caption]s were broken.
  • Image sizes were broken.
  • Some YouTube links were broken, in particular the ones that contained _ in their “code”

And probably a few more things are still broken that I haven’t found yet.

Hosting it in GitHub Pages

Follow the official Hugo guide:

Aftermath

Pros

  • To write posts in Markdown in my favorite editor.
  • To host the site using Git: source control, history, etc.
  • To have my images in the same place as the content. For different reasons, I was using Google Photos. Now, I’m just hosting them in GitHub.
  • Don’t have to pay for hosting, themes, and simple features like Google Analytics.

Cons

  • Lost all “comments” in the conversion.
  • No built-in comments: Hey, Hugo is a static site generator, it makes sense. There is support for 3rd-party comments services

Time spent

It took me around two days to do the entire process:

  • Conversion to Hugo, and fix issues
  • Setup Hugo
  • Setup GitHub Pages
  • Update DNS

So far, I’m happy with the result. But time will tell…