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] (https://gohugo.io/tools/migrations/). So instead we opted to use the wp2hugo.go tool to process the downloaded export file from Wordpress into markdown files, as explained [here] (https://eklausmeier.wordpress.com/2017/04/24/converting-wordpress-export-file-to-hugo/).
Create a ‘myblogsite’ directory where the source code will live.
Save [this file] (https://raw.githubusercontent.com/eklausme/c/master/wp2hugo.go) as ‘wp2hugo.go’ inside the ‘myblogsite’ directory
Within wordpress go to /wp-admin and export your site, unzip the downloaded file and place the xml file inside the ‘myblogsite’ directory
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
Links to image files still pointed to Wordpress, so these the files needed downloading and the links updating.
Review and update
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:
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] (/post/hugo-website-on-githubpages/)
Or if you need to use your own domain and SSL/TSL encryption, see the blog post [Hugo website hosted on GitLab Pages] (/post/hugo-website-on-gitlabpages/)