Moving From Jekyll to Hugo
After years of struggling with jekyll’s limitations and idiosyncracies, today I moved to hugo.
It took several hours.
Importing content
The Migrate to Hugo page suggests a few tools.
First I tried the jekyll import command built-in. It moved the posts correctly. But the filename retained the date prefix as in jekyll. And I wasn’t sure if the date was correctly captured in frontmatter.
Then I looked at the JekyllToHugo tool. It was just a simple python file. I liked this because I could change the behaviour to my liking. In fact, I did change a lot. I’m attaching the modified version of this at the end of this post.
Anyhow, with that I was able to get all the pages moved with dates removed from filename, and the frontmatter to my liking.
Changing theme
Instead of importing the theme, I just decided to start from a minimal theme. I copy pasted the content of nostyleplease theme into my themes/asd folder and started using that. I plan to add features as I like later. I’ve already added hugo’s internal partials for opengraph, etc.
Feed
To get atom feed, I used the file from kaushalmodi/hugo-atom-feed.
Tag URL
There was one small snag. On jekyll, my tags were coming in a URL like /tag/devops
. But on hugo it was at /tags/devops
.
The documentation about this is confusing. There a couple of discourse threads and a github issue for this. But no solution seemed to work. Eventually I looked into the test case added via the commit that closed that github issue. And doing the following in hugo.toml
worked
[taxonomies]
tag = 'tags'
[permalinks]
tags = "/tag/:slug"
You can see the whole diff here
Archetypes
I created an archetype called post.md and used this command to create this post: hugo new content --kind post moving-to-hugo.md
Appendix
Modified jekyllToHugo.py
View in Gitlab Snippet (since it contains what hugo interprets as a shortcode and fails rendering, I had to move it to gitlab)