Menu not rendering items

I’m having a bit of a time getting the menu to display - so far most problems I have run in to have been my own misunderstanding of how hugo works but this one I think I grasp but still not getting why no menu

I just copy pasted the code from another post - all that I’m getting is an empty <ul> tag on each page

config.toml

[menu]
  [[menu.main]]
    name = "Home"
    identifier = "home"
    url = "/"
    weight = 10

  [[menu.main]]
    name = "Blog"
    identifier = "blog"
    url = "/blog/"
    weight = 20

  [[menu.main]]
    name = "Contact"
    identifier = "contact-us"
    url = "/contact-us/"
    weight = 30

layouts/_default/baseof.html

<!DOCTYPE html>
<html lang="en">
  <head>
   ...
  </head>
  <body>
    {{block "main" . }}
    {{end}}
    {{block "scripts" . }}
    {{end}}
    {{partial "footer" }}
    {{partial "nav" }}
  </body>
</html>


partials/nav.html

{{ $currentNode := . }}
<ul>
{{ range .Site.Menus.main }}
    <li class="{{if or ($currentNode.IsMenuCurrent "main" .) ($currentNode.HasMenuCurrent "main" .) }}active{{end}}">
        <a href="{{ .URL }}">{{ .Name }}</a>
        {{ if .HasChildren }}
            <ul class="sub-menu">
                {{ range .Children }}
                    <li class="{{if $currentNode.HasMenuCurrent "main" . }}active{{ end }}">
                        <a href="{{ .URL }}">{{ .Name }}</a>
                    </li>
                {{ end }}
            </ul>
        {{ end }}
    </li>
{{ end }}
</ul>
1 Like

Try passing the context to the partial. Replace {{partial "nav" }} with {{partial "nav" . }}

3 Likes

ah “the dot” got me - that was it thank you.

1 Like