Hi,
so I have lots of posts, each has one or more tags. I also have a listing for each tag, e.g. /tags/unix
for the tag “unix”. I don’t know how to get the current tag in this list in the template.
This is how my template themes/$theme/layouts/_default/taxonomy.html
currently looks:
{{ define "main" }}
{{/* this works but I'm sure I'm not using it as intended */}}
{{ $tag := lower .Title}}
<h1>Posts on: {{ $tag }}</h1>
<content>
{{ $pages := where site.RegularPages "Params.tags" "intersect" (slice $tag) }}
{{ $paginator := .Paginate ($pages.GroupByDate "January 2006" "desc") }}
{{ range $paginator.PageGroups }}
{{ range .Pages }}
<h3><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h3>
<div>
{{ .Content }}
</div>
<p style="font-size: 0.6em; margin-bottom: 100px">
<i><a title="permalink" href="{{ .RelPermalink }}">↷ {{ time.Format "02.01.2006" .Date }}</a></i>
🠶
{{ range (.GetTerms "tags") }}
<a class="blog-tags" href="{{ .RelPermalink }}">#{{ lower .LinkTitle }}</a>
{{ end }}
<a href="#top">⤒</a>
</p>
{{ end }}
{{ end }}
{{ template "_internal/pagination.html" . }}
</content>
{{ end }}
This works as I want, that is, on the url /tags/unix/
it only lists pages which have the tag “unix”. However, I extract the current tag from the .Title
variable. I am pretty sure this is not the correct way to do it.
How would I do this correctly?