Tag cloud snippet for Hugo

Coding, Snippet, Hugo

Simple solution for tagcloud in your Hugo website.

{{ $tags := $.Site.Taxonomies.tags.ByCount }}
{{ $v1 := where $tags "Count" ">=" 3 }}
{{ $v2 := where $v1 "Term" "not in" (slice "hugo" "tags" "rss") }}
{{ range $v2 }}
{{ if .Term }}
{{ $tagURL := printf "tags/%s" .Term | relURL }}
<a href="{{ $tagURL }}">{{ .Term }} ({{ .Count }})</a>
{{ end }}
{{ end }}

Enjoyed this post? If you’d like to support me, I’d love if you could buy me a coffee.