I just started using Hugo with the Gokarna theme for my blog. Having seen multiple examples of TILs (“Today I Learned”) I also wanted to create a small corner on my blog for TIL-type content. However, Gokarna doesn’t support it by default.
So, here’s what I did to achieve proper separation.
- Create a new content folder in
/content/tilsto store your TIL markdown files. - Add a menu item in your
hugo.tomlfile to include the TIL section in the menu at the top right.
[[menu.main]]
name = "TILs"
url = "/tils/"
weight = 2
- Add the
til: truefront matter to your TIL files.
---
title: "How to separate TILs from Posts in Hugo's Gokarna theme"
date: 2025-02-14
type: "post"
til: true
---
- Update the
layouts/index.htmlfile in the Gokarna theme to exclude TILs from the posts list. Change this:
{{ $posts := where .Site.RegularPages "Params.type" "post" }}
To this:
{{ $posts := where (where .Site.RegularPages "Params.type" "post") "Params.til" "ne" true }}
I’m sure there is a more elegant solution where you don’t need to add the extra til: true metadata tag to each TIL-type post, but it was quick enough to change and it works.