September 4, 2017
From WordPress to Hugo
Why?
So I can move from shared hosting to static file hosting with Netlify or Firebase and not have to maintain a WordPress site.
How?
-
Export content from WordPress with https://github.com/SchumacherFM/wordpress-to-hugo-exporter. This WordPress plug-in made me a .zip file with all my posts converted to .md files and my uploads folder of images
-
Move all the .md files into the new Hugo site’s
content/posts
folder -
Move WordPress’s
uploads
folder to Hugo’sstatic
folder -
Eat lunch
-
Test new Hugo site and find issues
-
Write a config file. Copy all the options from https://gohugo.io/getting-started/configuration/#yaml-configuration and wittle them down to what I need like this
baseURL: http://kb.imakewebsites.ca googleAnalytics: [my uid here] permalinks: post: /:year/:month/:title/ sitemap: changefreq: monthly priority: 0.5 filename: sitemap.xml theme: ananke title: Knowledge Base
-
Fix lack of syntax highlighting by installing prism.js and doing a search and replace to change code like
<pre><code class="language-js"> [sample code here] </code></pre>
into
```js [sample code here] ```
-
Fix character encoding issues like
<
being replaced with>
unnecessarily in code samples -
Manually add
featured_image
info to front-matter for posts because that field wasn’t included in the WordPress export. -
Add
_index.md
file with content for homepage to/content
directory so that the homepage has some content -
Restart on theme, using https://themes.gohugo.io/blank/ as a base
-
Copy a bunch of CSS from http://www.imakewebsites.ca to style the blank theme (which has a surprisingly similar HTML structure to my own site)