Ordering Menu items

Weight is the default sort for menus in Hugo. Some variations below:

{{ range .Site.Data.Menu.Sort }}
{{ range .Site.Data.Menu.ByName }}
{{ range .Site.Data.Menu.ByName.Reverse }}
{{ range .Site.Data.Menu.ByName.Limit 10 }}
{{ range .Site.Data.Menu.ByWeight }}

I had the same problem and solved it by using negative numbers for the weight attribute.


Change the line:

{{ range .Site.Data.Menu }}

by:

{{ range sort .Site.Data.Menu "Weight"}}

That solved the problem for me.

Tags:

Hugo