I am building a site and want to have three levels of menus instead of the two levels I can currently achieve using Hugo.
For example, on my navigation bar I wish to have:
- Introduction
– Topic 1
— Page 1
— Page 2
– Topic 2
— Page 3
- Contact
…
I currently have menus in two levels, the top specified by a config.json, and then each page assigned into this menu using a header like the below:
+++
title = "Bulk API"
weight = 1
[main]
[menu.main]
parent = "bulk"
title = "Bulk API"
+++
I have looked at Multi-level menu using material design theme and also tried a large number of different permutations. I am including a snippet our current menu generating code here, which uses recursion on itself to render:
{{ range .menu.ByWeight }}
{{ $is := $page.IsMenuCurrent "main" . }}
{{ $has := $page.HasMenuCurrent "main" . }}
{{ if .HasChildren }}
<li>
<a href="{{ .URL }}" class="mdl-components__link parent{{ if $is }} is-active {{ end }}">
{{ .Name }}
</a>
{{ if .HasChildren }}
{{ if or $is $has }}
{{ partial "menu_recursive.html" (dict "menu" .Children "page" $page "site" $site "nested" true) }}
{{ end }}
{{ end }}
</li>
{{ else }}
<li>
<a href="{{ .URL }}" class="mdl-components__link parent{{ if $is }} is-active {{ end }}">
{{ .Name }}
</a>
</li>
{{ end }}
{{ end }}