# Multi-Level Menus

**URL:** <https://discourse.gohugo.io/t/multi-level-menus/7408>\
**Category:** support\
**Created:** [July 12, 2017, 2:15pm UTC](https://discourse.gohugo.io/t/multi-level-menus/7408 "2017-07-12T14:15:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmspeers](https://avatars.discourse-cdn.com/v4/letter/r/dfb087/32.png) [@rmspeers](https://discourse.gohugo.io/u/rmspeers)\
**Post date:** [July 12, 2017, 2:15pm UTC](https://discourse.gohugo.io/t/multi-level-menus/7408/1 "2017-07-12T14:15:08Z")

</div>

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](https://discourse.gohugo.io/t/multi-level-menu-using-material-design-theme/4324) 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 }}
```

---

<div class="post-metadata">

**Author:** ![rmspeers](https://avatars.discourse-cdn.com/v4/letter/r/dfb087/32.png) [@rmspeers](https://discourse.gohugo.io/u/rmspeers)\
**Post date:** [July 12, 2017, 6:44pm UTC](https://discourse.gohugo.io/t/multi-level-menus/7408/2 "2017-07-12T18:44:31Z")

</div>

I got this partially working using \_index.md pages in the sub-folders of the tree, however there are a few issues:

- The main issue is that these sub-pages in my menu all have $is set, e.g. in my above example when I click on Topic 1, then the following items have $is set which causes highlighting: Topic 1, Topic 2, Introduction. I think this is because the page “Topic 1” links to is really the same page as “Introduction” – it isn’t creating a listing page for just the things under the Topic 1 folder in my content tree structure.
- I have to use parent="" in my front-matter pointing to the name of the “sub category” given in my \_index.md, it would be nice to point to the name of the subfolder for that sub-category, or have a more programmatic (e.g., not english text) “id” element.

---

<div class="post-metadata">

**Author:** ![rmspeers](https://avatars.discourse-cdn.com/v4/letter/r/dfb087/32.png) [@rmspeers](https://discourse.gohugo.io/u/rmspeers)\
**Post date:** [July 17, 2017, 12:51pm UTC](https://discourse.gohugo.io/t/multi-level-menus/7408/3 "2017-07-17T12:51:10Z")

</div>

Just an update: This mostly works using [https://github.com/dropseedlabs/sibbell-public/issues/21](https://github.com/dropseedlabs/sibbell-public/issues/21) (v0.22), but there are still some issues that I have – which are different enough from the original question here that I have opened [Determining Current Menu Parent with Sections (not explicit menu)](https://discourse.gohugo.io/t/determining-current-menu-parent-with-sections-not-explicit-menu/7473).
