I found a web site documenting how to create a menu with submenus and I copied the nav.html file from that site. There’s an error in nav.html. The file:
<nav class="nav">
<ul class="menu">
{{ range .Site.Menus.main }}
<li class="{{ if $currentPage.HasMenuCurrent "main" . }}active{{ end }}">
<span>{{ .Name }}</span>
{{ if .HasChildren }}
<span class="drop-icon" for="{{ .Name }}">▾</span>
<ul class="sub-menu">
{{ range .Children }}
<li class="{{ if $currentPage.HasMenuCurrent "main" . }}active{{ end }}">
<span>{{ .Name }}</span>
</li>
{{ end }}
</ul>
{{ end }}
</li>
{{ end }}
</ul>
</nav>
This throws an error when I try to invoke hugo server:
$ hugo server
Error: add site dependencies: load resources: loading templates:
"../layouts/partials/nav.html:4:1":
parse failed: template: partials/nav.html:4: undefined variable
"$currentPage"
Where do I define $currentPage so Hugo accepts the variable?