Loop through categories & tags

I use the following partial in all single templates, get what you need

{{if not .IsHome -}}
<div class="b no-print w-100">
{{if (ne .Type "menu") -}}<span class=nowrap><a href="/" title="{{ $.Scratch.Get "home" }}"><i class="fas fa-home fa-fw"></i></a>

{{ if isset .Params "categories" -}}
  {{ range $index, $name := sort .Params.categories -}}
	{{ with site.GetPage (printf "/%s" ($name | urlize )) -}} 
		<a class=ph1 href="{{ .RelPermalink }}" title="Bereich: {{ .Name | markdownify}}">{{ .Name | markdownify}}</a> 
	{{- end}}
  {{- end }}
{{ end }}
</span>

{{ if isset .Params "tags" -}}
	<span class=nowrap>
	<a href="/tag/" title="{{ $.Scratch.Get "index" }}"><i class="fas fa-tag fa-fw"></i></a>
	{{ range $index, $name := sort .Params.tags -}}
		<a class=ph1 href={{ (printf "/tag/%s/" $name) | urlize }} title="Index: {{$name | markdownify }}">{{$name | markdownify}}</a>
	{{- end}}
	</span>
{{- end }}

{{- end}}
</div>
{{- end}}
2 Likes