Migrate from wordpress to hugo

· Read in about 2 min · (345 Words)

Why abandon wordpress

It’s too heavy to my VPS, even with cache plugin. Static page is much more faster!

Why Hugo

See official doc: http://gohugo.io/

  • Hugo is written in golang. It’s just an tiny executable binary file available for most popular operating system.
  • All pages are written in Markdown.
  • Hugo contains a super fast web server, it could monitor file changes and sync the contents in all most realtime (~200 ms for 100 pages).

Quick try

Go to download page and get file of your platform.

Uncompress the .zip file and copy executable file hugo to /usr/local/bin (for Windows user, copy hugo.exe to C:\WINDOWS\system32) and enter an empty directory in command-line interface.

Create a new site, sitename and dirname do not mater and are editable:

hugo new site sitename dirname

Create page. It will be in dirname/content/

cd dirname
hugo new about.md

Create post page and add some content.

hugo new post/test.md

Start hugo server, and browse on http://localhost:1313

hugo server

Learn more on official site.

Deploy to github pages

Create a repository on github.

Generate static pages to public directory

hugo

Now you can push content in public to github repository.

You can also bind domain name to github page. See more

Import post and pages from wordpress

I used and Wordpress plugin wordpress-to-hugo-exporter. After installation and activation, export data from the command-line (webpage tool failed):

cd wp-content/plugins/wordpress-to-hugo-exporter-master
sudo php hugo-export-cli.php
scp user@ip:/tmp/wp-hugo.zip .

You will find the exported markdown files may contain some unwanted meta data, It depends the installed plugins of your Wordpress site.

views:
  - 338
dsq_thread_id:
  - 1414379891
bot_views:
  - 248
ratings_users:
  - 2
ratings_score:
  - 10
ratings_average:
  - 5

And I had to delete author and layout to make it works.

author: shenwei
layout: post

And some css styles also were exported, I spent plenty of time to clean it. So, you may considerate to build an fresh new site by hugo.

Other guide

You can also imported command hugo imort jekyll to import data from Jekyll files which could be exported from Wordpress by some tools like wordpress-to-hugo-exporter.