Automatically defined menu items have weight set to 0

I’m using sectionPagesMenu: main in my hugo.yaml to add my /blog/ section to the menu, and then menu: main in the frontmatter of my /links/ page to add it to the menu. Then I’m just using {{ range .Site.Menus.main }} to list everything on my nav bar.

This has been working fine as I was happy with the alphabetical sorting, but just now I wanted to add a new page to the menu and explicitly make it go to the end. I tried setting weight on it specifically, but it goes to the front instead. It looks like this might be because the Blog and Links menu items that I had added before without explicitly setting a weight causes it to have a weight of 0.

Here’s a picture with {{ .Weight }} added inside the range:

image

Is there a way to fix this without having to manually define the weight on each menu entry? I would’ve expected that the current “default” of 0 would work fine so if I make numbers >0 then it goes to the end, and <0 goes to the front of the default-weighted items.

No.

https://gohugo.io/quick-reference/glossary/#weight

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