Sort by tag name

I’m tagging my pages with things such as foo and bar. Now I’d like to use pages /tags/foo/ to provide more information about tag foo, such as (for foo)

title: A weird word

and (for bar)

title: Another weird word

By default, it appears that a range over all tags orders things by the title that I just provided. But I’d like to order things by tag name (in other words, bar comes before foo, instead of A weird word comes before Another weird word).

I tried:

range sort .Pages ".Data.Term"

and variations but no cigar. How do I do this correctly?


{{ define "main" }}
  <h1>{{ .Title }}</h1>
  {{ range .Data.Terms.Alphabetical }}
    <h2><a href="{{ .Page.RelPermalink }}">{{ .Page.Title }} ({{ .Term }})</a></h2>
  {{ end }}
{{ end }}

Working example:

git clone --single-branch -b hugo-forum-topic-29850 hugo-forum-topic-29850
cd hugo-forum-topic-29850
hugo server

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.