Hugo

| Tags: blogging

I read about that new static site generator called “Hugo”. It was said to be really fast, much faster than Jekyll. Well, build performance isn’t an issue for my website and currently it doesn’t seem to ever become an issue. During the 17 years my blog exists I wrote 290 posts and there are a few other pages. Jekyll only needed seconds to build it. Performance would therefore not be a reason to change from Jekyll to Hugo. I just wanted to try something new.

I made Hugo create a scaffolding for me and copied my posts into that structure and started tinkering with it. It was an opportunity to look into the go programming language and while doing that I came to the conclusion that it is OK but doesn’t excite me much. And you actually don’t need to know much about go if you only use Hugo and do not take part in the development of it, but it helps to know the basics. And you totally have to learn go templates because that is the template language used by Hugo.

I prefer go templates to liquid which is used by Jekyll. go templates look nicer. That’s also not really a pressing reason to switch to Hugo but it adds to the overall good opinion about it.

While Hugo is probably mostly used for blogs it can be used for all kinds of websites and blog posts don’t have a special meaning like they have in other generators like Jekyll. Blog posts are just a collection of markdown files that are typically placed in a folder called content/posts but that is actually only a convention and you can put them somewhere else. And you can have other collections as well. You just define how the permalinks for the items of a collection shall look and then you add a template file for the pages for the single items and one for the list of those items. And if you need, you just add paging to that list and it will be split into multiple pages. You don’t need to install any additional modules. This is all part of the core Hugo. Tagging is also there out of the box and the creation of a menu for the sections of a website is a no-brainer.

That generic handling of lists of pages has one effect that is a bit disturbing at first if you migrate from a website generator like Jekyll that has special handling for blogs. There are no yearly and monthly archives. The Hugo forums have some discussions about this and some people have come up with creative workarounds. My blog always had archives and I was very intent to recreate them with Hugo. But it’s quite understandable that Hugo does not have archives. This is how you define permalinks in the Hugo configuration

  permalinks:
    posts: /:year/:month/:filename/
    tags: /tag/:title/

Ah, OK. For the pages in the posts collections, there is a year and month in the permalink. Fine. And for tags there’s a title in there. Also fine. And that’s it.

After looking at some of the creative workarounds and thinking about archives I realized that I never looked into any archives on the blogs I read. Mostly I read them in my feed reader. And when I visit a blog website itself in most cases I do so because I clicked on some link. I never look at what someone wrote in some specific month or year. I may look at other posts with the same tags and I might browse older posts, but I never use yearly and monthly archives. With that insight I decided that I don’t need archives.

But where would I put my tag cloud when there is no archives page? Should I put it on each page? Some years ago tag clouds were the cool stuff and each blog had to have them on each page and clearly visible. But tag clouds aren’t that exciting anymore and they probably never were anyways. Content is more important. So no, no tag clouds on every page. You can still look at my nice tag cloud which is now located at the bottom of every tag page. It actually looks nicer now. It uses logarithmic distribution and is styled a bit nicer. Take a look at the blogging tag as an example.

That generic list handling greatly simplifies the maintenance of the creations section. In the Jekyll version of this website I had pages for each piece of software I wanted to present there and an index page with short intros and links to those pages. Now I only have markdown files for those single pages and one template for the single page and one for the list and the list extracts the intro from the front matter of those markdown files. There is probably a better solution for this with Jekyll than how I did it, but it wasn’t apparent to me and with Hugo it was obvious.

As to be expected for a static website generator there are tons of themes for Hugo and every week or so another one is released. I’ve never been one to use prefabricated themes. What better opportunity to play around with html and css than to do it on the own website. The website looks mostly like it looked with Jekyll. The structure of the pages hasn’t changed and I actually translated the layouts from Jekyll and liquid to Hugo and go templates. I changed the icons that I use from FontAwesome a bit. I now only use the solid variant everywhere.

I like that Hugo already contains all I need for my website. There’s no need to install and update any plugins. I just update Hugo with homebrew when a new version becomes available and that’s it.

If you are on the search for a static website generator or just want to try a new one, I recommend to look into Hugo even if build performance is not really an issue. Hugo comes with extensive documentation and often there are also tutorial videos showing how things work. It takes some time to understand how Hugo works but learning is fun and pays off.