A Few Hugo Snippets That Are Enough to Keep This Blog Growing
Contents
Homepage post list
Sometimes you only want posts under the blog section:
{{ $posts := where site.RegularPages "Section" "blog" }}
{{ range first 5 $posts }}
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
{{ end }}
Tag links
Turn tags into clickable links:
{{ range .Params.tags }}
<a href="{{ (printf "/tags/%s/" (. | urlize)) | relURL }}">{{ . }}</a>
{{ end }}
A minimal menu in config
[[main]]
name = "Posts"
url = "/blog/"
weight = 20
Why keep these snippets
Because a reusable snippet is often more valuable in the long run than searching for the same answer again.