Menu structure from file system

The way I am doing a Conditional Section Menu is by displaying Hugo Menu Items based on a conditional check of the Menu Item .URL vs the Page .Type (Note: .Type is an alias of .Section).

So provided that you have configured a standard Hugo Menu for your Section and Nested Sections called .Menus.section (look into the Docs for Menu configuration -I’m not going into the specifics-)

You can do the following:

{{ range .Site.Menus.section }}   
{{ if (strings.Contains .URL $.Type) }}
<a href="{{ .URL }}">{{ .Name }}</a>   
{{ end }}   
{{ end }}
1 Like