Sort taxonomy by custom metadata Front Matter

I would like to display and order a taxonomy by a piece of metdata in this case an order integer. I’ve added custom metadata as per hugos docs: Add custom metadata

---
colour: "#4A4A4A"
order: 6
excerpt: "this is my except"
title: "This is the title"
period: "Pre history"
---

When using {{ range .Site.Taxonomies.sets }} on my homepage layout how would I go about ordering the sets by the order parameter? I can’t use alphabetical or count as these wont help my ordering as each set can contain different numbers of items.

In my terms template I’ve been able to do this using: {{ range .Pages.ByParam “order” }} but cant see how I’d achieve this in a partial to be placed in to my homepage layout.

Any suggestions?

Have you tried sort:

{{ range sort .Site.Taxonomies.tags ".Page.Params.order" "asc" }}
  {{ .Page.Params.order }} / {{.Page}} <br>
{{ end }}
1 Like

You have been super helpful, this has worked. I did try sort last night but it was late and wasn’t getting anywhere. This has done the trick.

It might be nice to include this example in the taxonomy docs as an alternative sort method.

Thank you so much for your help.

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