Wordpress to Hugo

August 2, 2017

How we migrated a Wordpress blog to a Hugo generated website (and hosted it on GitHub Pages for free), without too much fuss.

Part 1: Export from Wordpress to Hugo format:

Being on the free tier of Wordpress, it was not possible to run any of the excellent looking tools that hugo recommends. So instead we opted to use the wp2hugo.go tool to process the downloaded export file from Wordpress into markdown files, as explained here.


  1. Create a ‘myblogsite’ directory where the source code will live.
  2. Save this file as ‘wp2hugo.go’ inside the ‘myblogsite’ directory
  3. Within wordpress go to /wp-admin and export your site, unzip the downloaded file and place the xml file inside the ‘myblogsite’ directory
  4. Install go, if not already installed, then run the conversion:

    $ sudo apt install golang-go
    $ cd myblogsite
    $ go run wp2hugo.go myblogsite.wordpress.2017-08-02.001.xml

    This generates all of the files and directories as if you had run$ hugo new myblogsite

Tidying up:

  1. Links to image files still pointed to Wordpress, so these the files needed downloading and the links updating.
  2. Review and update /config.toml
  3. Consider removing dates from the URLs - by simply moving all the post / .md files out of the date directories and into the root of the ‘post’ directory.

    For example move the ‘a-blog-post.md’ file from:

    /content/post/2017/08/04/a-blog-post.md => http://myblogsite/post/2017/08/04/a-blog-post


    /content/post/a-blog-post.md => http://myblogsite/content/post/a-blog-post

Part 2: Host the Hugo website on GitHub / GitLab Pages

For how we hosted myblogsite on GitHub Pages, see the next blog post Hugo website hosted on GitHub Pages

Or if you need to use your own domain and SSL/TSL encryption, see the blog post Hugo website hosted on GitLab Pages

© 2019 Keith P | Follow on Twitter | Git