Hugo-logo
Hugo-logo

Hugo is a static website and has no dynamic services like comments. Comments can be done by using Disqus, an external service. Also all known “old” Wordpress URL’s needs to be serviced by the new Hugo website and not working URL’s needs to be forwarded. It’s not good for your search machine (Google) ranking, to have not working URL’s.

Install Hugo

In the Hugo Quickstart, you can find how to install Hugo including a theme and other important basic things. It’s a clear description, not very useful ro repeat the same things.

Migration of your Wordpress comments to Disqus

At point of the migration process your old Wordpress website should still online. Now we can export the internal Wordpress comments to Disqus:

  1. Signup for a Disqus account here for free: Disqus.com
  2. For Hugo you need to know your Disqus Shortname. What and how to get this, is described here: What’s a shortname?
  3. Install in Wordpress the: Disqus Comment System
  4. Activate this plugin
  5. How to export is nicely written in this howto: Importing comments from WordPress

Fill in your config.toml the following:

# Enable comments by entering your Disqus shortname
disqusShortname = "examplename"

Fixing not working URL’s

The conversion tools, are also converting your URL’s of your posts and pages. In the markdown header you need to have, for example:

url: /migration-from-wordpresss-to-hugo/

If you need an old URL (one or more) to be forwarded to an post or page, you can use in the header:

aliases:
- /project/migration-wordpress-to-hugo/

Check your sitemap.xml of your old Wordpress website, which URL’s you’re publishing right now. And check in your Hugo website, what will work and what needs to be forwarded.

  • /contact/ -> /#about
  • /about/ -> /#about
  • /tag/ -> /tags/
  • /subject/ -> /categories/
  • /wp-content/uploads/ -> ../../../post-img/

The first 2, I put it as an aliases setting in the about.md file:

aliases:
- /about/
- /contact/

The Wordpress imaged are moved to /img and the tag path was changed into tags and subject into categories. To forward these paths permanently, you can use the following configuration for Nginx, or an .htaccess file in Apache.

vi /etc/nginx/sites-available/example.com
...
location /tag/ {
    rewrite ^/tag/(.*)$ https://example.com/tags/$1 permanent;
}
location /subject/ {
    rewrite ^/subject/(.*)$ https://example.com/categories/$1 permanent;
}
location /wp-content/uploads/ {
    rewrite ^/wp-content/uploads/(.*)$ https://example.com../../../post-img/$1 permanent;
}
...

Google Analytics

If you are using Google Analytics, you need to tell in config.toml, which tracking ID you have:

# Enable analytics by entering your Google Analytics tracking ID
googleAnalytics = "UA-XXXXXXXX-X"

This was all I needed to do for my website. But check the functionality of your old Wordpress website, and look how to migrate this to Hugo.


The next posts are guiding you through how to use Hugo:

  1. Why changing from WordPress to Hugo
  2. Conversion tools from Wordpress to Hugo
  3. Migrating from Wordpress to Hugo