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/_index.md 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?

layouts/_default/taxonomy.html

{{ 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 https://github.com/jmooring/hugo-testing hugo-forum-topic-29850
cd hugo-forum-topic-29850
hugo server
2 Likes

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