Contents

A Few Hugo Snippets That Are Enough to Keep This Blog Growing

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 }}

Turn tags into clickable links:

{{ range .Params.tags }}
  <a href="{{ (printf "/tags/%s/" (. | urlize)) | relURL }}">{{ . }}</a>
{{ end }}
[[main]]
name = "Posts"
url = "/blog/"
weight = 20

Because a reusable snippet is often more valuable in the long run than searching for the same answer again.