How To Migrate a Website from Wordpress to Hugo
I decided to migrate this website from Wordpress to Hugo for two reasons:
- Static websites are faster than database-driven
- Static websites are cheaper
Here’s how I did it.
1. Decide Whether Leaving WordPress Is Possible
3 Things to consider before leaving Wordpress
- Search
- Forms
- plugins
1.1 Search
https://gohugo.io/tools/search/ details various options for adding search to your Hugo website.
1.2 Forms
My preferred site for hosting is currently Netlify.
They offer forms as an extra.
I could also look again at:
- mailchimp Forms
- sumome
- wufoo shortcode forms
1.3 Plugins
Login at
Check the plugins - are there any that might stop me turning this into a static site?
In my case, I have these:
- Akismet Anti-Spam. for checking comments.
- Cloudflare. for speeding up delivery of websites
- Elegant Themes Updater
- Yoast SEO
and also had unactivated:
- Absolute Privacy
- Disqus Comment system
- Mailchimp Forms by Optin Cat
- SumoMe
- Wufoo Shortcode Plugin
Let’s look at those each in turn.
Akismet Anti-Spam & Comments
You only need to protect your website comments if you allow people to make them.
I have 2 choices here:
- allow comments
- do not allow them
I do not care about keeping the old comments from WordPress.
I do care about having comments for the new posts I am going to write, so I need to find a solution to this.
Hugo comes with Disqus support included, but there are alternatives.
https://gohugo.io/content-management/comments
- https://github.com/umputun/remark looks interesting because it claims it can import from wordpress and disqus. and it sends telegram notifications.
https://utteranc.es/ looks interesting because it uses github PRs
https://www.talkyard.io/ looks good too.
In the end, I went with Disqus because it was the easiest solution.
Cloudflare
Netlify comes with its own CDN and HTTPS support. So I don’t need this.
Elegant Themes Updater
Not using a WP theme from Elegant Themes, so this can go too.
Yoast SEO
Not sure about this.
Can use https://developers.google.com/speed/pagespeed/insights/ or their other tools to check pages?
2. Setup exitwp
There’s a few tools available for translating a WordPress export into a Hugo site; I went with
https://github.com/wooni005/exitwp-for-hugo
git clone https://github.com/wooni005/exitwp-for-hugo.git
cd exitwp-for-hugo
virtualenv -p python2 venv
venv/bin/pip install pip_requirements.txt
2. Export from WordPress
Once you’ve logged into WordPress, go to Tools>Export.
Select all content then press “Download Export File”.
Download the file to the exitwp-for-hugo/wordpress-xml directory.
$ venv/bin/python ./exitwp.py
This creates a set of hugo files in build.
3. Create Hugo website
Create a standard hugo site, and copy those files into content.
You may need to rename the files from “.markdown” to “.md”, depending on your site’s config.
cd site/content/post
for x in *.markdown
do
name=${x%.markdown}
mv $name.markdown $name.md
done
4. Getting it live
Create a Gitlab project and push the new site up following their instructions.
Create a Netlify project, and connect to Gitlab.
5. Set up Netlify Identity
I need this because my site uses netlify-cms to provide a web-based editing option.
Inside the Netlify project:
- enable Identity project
- inside Identity, enable Git Gateway
- invite myself as first user
6. Go live
- Switch over the DNS.
- Set Netlify to recognise the DNS name
- Turn off WordPress
7. Enjoy
3 things I really like about this set up:
- Changes are version-controlled
- Automatic deployment after ‘git push’
- Can write posts using normal editor