Example for OrderedTaxonomy?

I’m currently migrating a bigger E-Commerce Page from CQ5 to hugo and I’m having a problem with a hierarchical taxonomy. The original one has to levels like main category and sub category. Then follows the content.
To maintain the current order, I thought OrderedTaxonomies might be a good idea, but I don’t understand the example. Questions are:

Where to put the definition of the taxonomy. Still in the fron matter of the content (but that wouldn’t make that much sense due to ordering, right?) ? Would this be something like

mainCategory: []struct {

And what are WeightedPages? I could not find any example for that. Can anyone point me in the right direction or to an existing project on github using this?


The terms you use seem to be taken from the source code.



It talks about two things:

  1. Order the way the keys for a taxonomy are displayed
  2. Order the way taxonomyed content appears

Taxonomies aren’t hierarchical by design, but there have been discussions about workarounds in this forum (search?) – but that will mean some double book keeping.

Thanks for the reply. But as far as I understand, you can order taxonomies itself (not the content) either alphabetically or by popularity. If you want a different order, you should use http://gohugo.io/taxonomies/methods/
And the example code

[]struct {
     Name          string
     WeightedPages WeightedPages

does not help me to dive deeper into this. Sorry, if I missed something obvious here…

Ah, OK – I see the documentation you point to is very “source code” like … And could be improved. Other will chime in, I’m a little busy now, but will try to explain later.

OrderedTaxonomy seems like it has great potential for your needs, but I agree there’s not a lot of detail about actually implementing it.

A different direction you could go is to just use the frontmatter ‘weight’ to control your ordering. This is in line with bep’s concern about probably double book keeping, but the default sort is by weight -> date (iirc). Some details http://discuss.gohugo.io/t/how-do-you-sort-custom-section-posts-by-front-matter-variable-solved/1034

I don’t think it’s the ideal solution, but it might be the quickest.

thanks for the hint, but as far as I understand, the weight - also the taxonomy_weight - controls the order of the content in the taxonomy view, not the taxonomy term itself. Thats why I need the ordered taxonomy. I also tried different approaches with menus. But I cannot “range over” the content associated with a certain parent menu.
I’m a bit lost at the moment…