Hello. I am creating a menu using hugo. I want to add myself an indication of the current page. To do this, there is the following code:
{{- $currentPage := .CurrentPage -}}
{{ if .URL }}
<a href="{{ .URL }}">
{{ end }}
{{ if $currentPage.IsMenuCurrent "main" . -}}
<b>{{- .Name -}} 1</b>
{{- else if $currentPage.HasMenuCurrent "main" . -}}
<b>{{- .Name -}} 2</b>
{{- else -}}
{{- .Name -}} 3
{{- end -}}
{{ if .URL }}
</a>
{{ end }}
But it doesn’t work (executed branch if else with number 3). When I want to check variables:
{{ print $currentPage }}
{{ print .CurrentPage }}
I am getting nil. What have I done wrong?