What is the best approach for sorting and grouping by custom field?

My site will have people, stored in content/people. In the front matter people will be assigned a rank (Chief, Capt, Lt. or None). On the people list page, the higher the rank, the bigger and more prominent they will be and more info will be provided (probably by calling different partials). They will also be sorted by highest (Chief) to lowest (None) rank. Something like the below.

  • Chief - name, picture, contact, bio
  • Captain - name, picture, bio
  • Lt - name, bio
  • None - name only

I would like the ranks to be editable as well (via NetlifyCMS). The end user can edit the abbreviation, duties and insignia icon of the rank.

I know with Hugo there is at least 1000 ways to accomplish this. My first thought is to make rank a taxonomy and attempt to filter the pages by “Section” “people”, then sort by the rank taxonomy weight. I could also store ranks as pages in content/rank or put ranks into a json data file.

I want the end hugo code to be as simple as possible. I don’t mind digging into the docs and working through the code myself but I would like to be heading down the right path first. How would you structure and store the information?

people = posts
rank = taxonomy
chief/captain/lt/none = taxonomy term in rank
sorting taxonomy terms = weight frontmatter in content/rank/TERM/_index.md frontmatter


Read Introduction to Hugo Templating | Hugo to learn more about how to “select” from your taxonomies and terms in your list and page templates.

Basically, you are right with your assumptions. Start doing it :slight_smile:


Excellent! Thank you for your help and keeping me from wasting hours creating some janky code.