Menu Weight as 0 Ignores Order By Weight

I setup the config.yaml to have the menu weights like this:

    - weight: 0
      identifier: blog
      name: Blog
      url: "/blog"
    # ...
    - weight: 4
      identifier: contact
      name: Contact
      url: "/#contact"

And on the layout for the navbar menu, I have this in the range:

{{ range .Site.Menus.main.ByWeight }}
<li><a href="{{ .URL }}">{{ .Name }}</a></li>
{{ end }}

But when it gets rendered, it didn’t put the menu items in order as if it’s ignoring the weights I gave it. Is there anything I am missing either in the menu config or the templating?

For page weights, 0 equates to undefined.
It’s probably the same for menu weights.
Change the blog weight from 0 to 1.

That is an interesting quirk to deal with but regardless, the problem is quickly resolved. Thank you.

Agreed. You can use negative or positive integers, but not zero.


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