Hugo List Pages of Specific Taxonomy

I wanted the section “Related Blog posts” in “Hello WWW” to be auto generated from posts with a certain category; in my case meta.

Update: [TODO] This can possibly be achieved much cleaner using the index function.

After some googling and lots of try and error, I came up with the following solution:

I created a shortcode layouts/shortcodes/list-category.html:

{{ $category := .Get 0 }}
<ul>
    {{ with .Site.GetPage (printf "/categories/%s" ( urlize $category )) }}
    {{ range .Pages }}
    {{ .Render "li"}}
    {{ end }}
    {{ end }}
</ul>

that can be used in my content.md file like so:

{{ < list-category "meta" > }}