Hi guys, I tried to highlight current menu and it doesn’t work for me. I checked docs and forum and I did not find answer.
- I made fresh clean hugo page (version 0.36.1)
- I created a.md, b.md and c.md pages
- This is my code:
config.toml
baseURL = "http://example.org/"
languageCode = "en-us"
title = "My New Hugo Site"
[[menu.main]]
name = "Home"
identifier = "home"
url = "/"
weight = 10
[[menu.main]]
name = "A"
identifier = "a"
url = "/a/"
weight = 20
[[menu.main]]
name = "B"
identifier = "b"
url = "/b/"
weight = 30
[[menu.main]]
name = "C"
identifier = "c"
url = "/c/"
weight = 40
single html
<!doctype html>
<html lang="en">
<head>
<title>test</title>
</head>
<body>
<h1>{{.Title}}</h1>
<div>{{.Content}}</div>
{{ $currentPage := . }}
<ul>
{{ range .Site.Menus.main }}
<li>
{{ .Name }}
| IsMenuCurrent = {{ $currentPage.IsMenuCurrent "main" . }} |
| $currentPage = {{ $currentPage }}
| menuItem = {{ . }}
</li>
{{ end }}
</ul>
</body>
</html>
and result for menu B is:
B
bbb
Home | IsMenuCurrent = false | | $currentPage = Page("B") | menuItem = {/ <nil> Home main home 10 []}
A | IsMenuCurrent = false | | $currentPage = Page("B") | menuItem = {/a/ <nil> A main a 20 []}
B | IsMenuCurrent = false | | $currentPage = Page("B") | menuItem = {/b/ <nil> B main b 30 []}
C | IsMenuCurrent = false | | $currentPage = Page("B") | menuItem = {/c/ <nil> C main c 40 []}
B should be current menu but is not.
Do you have any idea where is a problem?
Thanks.