Is it possible to sort taxonomy terms based on a set term weight?

The answer to your question is in the post I linked to.

I did not copy that code block in its entirety because I thought you wanted a sorted taxonomy terms list, (I hadn’t read every post above).

In any case it’s certainly doable to render the list as you ask, like this:

{{ define "main"}}
{{ $taxo := "categories" }}
<ul>
  {{ with ($.Site.GetPage (printf "/%s" $taxo)) }}
    {{ range .Pages.ByWeight }}
      <li><a href="{{ .RelPermalink }}">{{ .File.Dir | title }}</a>
<ul>
          {{ range .Pages }}
          <!-- this also lists the content pages associated with the term; 
               remove if not needed. -->
          <li>{{ .Title }}</li>
          {{ end }}
        </ul>
</li>
    {{ end }}
  {{ end }}
</ul>
{{ end }}

Screenshot of end result:

sorted-taxa

4 Likes