Migrating from Jekyll to Hugo



Let me be honest. Migrating from Jekyll to Hugo was not as easy as I thought.

The first problem was understanding the folder structure. The Hugo manual was not very clear about the best practise. I have figured out that you need at least three files. You need an ‘index.html’ for the front page which you should place in your ‘layouts’ folder. Additionally you need a ‘_default’ folder with a ‘single.html’ and a ‘list.html’ file in it. Their name tells you what they do: listing the content of a specific content type (section) and displaying a single content file. If you want an alternative list template for ‘posts’ (or any other content type, called ‘section’), just create a folder next to your ‘_default’ folder with the name of your content type, in this case ‘posts’.

The second problem was the Go templating language. It is not very straight forward, and I had a very hard time getting it to work. For example {{ if gt (len . ) 0 }} appears to be valid in the ‘Go templating language’. You have to know that in this language the function always comes first. The example {{ if gt (len . ) 0 }} litteraly means ‘if | greater than | length of the current item | zero’. You have to understand this means ‘if the length of the current item is greater than zero’. From a language/grammer point this is not very logical. This becomes a major headache when it comes to slightly complexer statements like this: {{ if and (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}. The notation is not like any other language I knew, which made even basic logic very hard to implement (despite my 10 years of programming experience). The learning curve of Go is extremely steep. Amber and Ace did not help.

The third problem was Forestry.io. I had been using CloudCannon with Jekyll and I turned out to be spoiled. Forestry has some very specific ideas about how my markdown should be formatted. For example, they require an empy line in the end of the YML/front matter block. Also, the content should start immediately after the end of the front matter. A new-line there is not allowed. Not following their code-style lead to unwanted code updates enforcing this nonetheless, resulting in an extra pull and merge for every push I did. Additionally, their updates broke my code more than once, because they had problems with parsing big inline SVG files. Using Forestry.io feels like working with an stubborn co-worker. Not very pleasant to say the least. But I should not complain too much… as it is pretty awesome that their service is free (and most people actually HAVE stubborn co-workers, and they manage too).

But hey… my Jekyll Codex website takes 1425 milliseconds to build, while this website builds in under 100 milliseconds. That is more than 10 times faster. That must be worth something.

Share on: