Pre-requisities

  • Access to WordPress dashboard.
  • Basic understanding of using command line.
  • Site generator (my choice Hugo).
  • Theme for the static site (my choice PaperMod).
  • CloudFlare account (Free hosting on CloudFlare Pages).

1. Export WordPress to XML

The first step would be to generate an XML file which is basically in the format of WordPress eXtended RSS (WXR) and contains all the data (posts, pages, comments etc). To do this:

  • Login to you WordPress dashboard » Tools » Export.
  • Choose “All content” for “Choose what to export”.
  • Click on “Download Export File” and save it to a location on your computer.

2. Install package - wordpress-export-to-markdown

We would be using a tool called wordpress-export-to-markdown.

  • This tool is built using Node.js so you would have to install it if not already installed.
  • Once done clone the above repo.
  • Navigate into the cloned repository directory.
  • Copy the file exported from WordPress into this directory.
  • Run npm install && node index.js.
  • Do note that the tool offers a lot of options, see the tool’s documentation for details.
  • I went with the default options, which meant:
    • All posts got it’s own folder, the folder name being the posts slug.
    • There was an ‘index.md’ created inside this folder which had all the post content in markdown format.
    • Images were downloaded and stored under images sub-directory of each posts folder.

3. Install Hugo and setup the blog

The next step is to install Hugo and do all the required setups to get the blog running locally.

4. Deploy

The next step can take various forms, but for this site I initially went with Commit to Bitbucket > Pipeline Build > S3 deploy > CloudFront. Then as I looked further I found CloudFlare Pages, since my site was already using CloudFlare for DNS and basic CDN for over 10 years now, I read about it further and saw that it was very easy to configure and the free plan is very flexible. So I went with CloudFlare Pages, the only drawback was I had to move from BitBucket to Github as it supports only Github and Gitlab for now for the automated builds.

The main drawback with CloudFlare pages at the moment is that it would take about 4-5 minutes to do a build. Other than that the amount of features they provide on a free plan is note worthy.

So that’s how I migrated from WordPress to Hugo and setup a static site. I also use Disqus for comments, but that is pretty straight forward process. If you have any questions, do let me know through the comments below.