HUGO

Menus Custom Params

I have this menu and i want to access to Params

[[Languages.en.menu.main]]
    name = "Home"
    pre = "#"
    url = "home"
    weight = 1
    [Languages.en.menu.main.params]
        useBaseUrl = true

I want to access to the Menus Parameters

<ul class="navbar-nav  ml-auto">
				{{ range site.Menus.main }}
				<li class="nav-item">
					{{ $siteBaseUrl := "" }}

					{{ with .Params.useBaseUrl }}
						{{ if eq . false }}
							<!-- parameter set to false -->
							{{ $siteBaseUrl := "" }}
						{{ else }}
							<!-- parameter not set to false-->
							{{ $siteBaseUrl := (site.BaseURL | absLangURL) }}
						{{ end }}
					{{ else }}
						<!-- template logic for pages that do not have the useBaseUrl parameter -->
                                   {{ printf "%" .Params }} <!-- this is the result %!(NOVERB)%!(EXTRA maps.Params=map[useBaseUrl:true]) -->
					{{ end }}
					<a class="nav-link js-scroll-trigger" href="{{if .Pre}}{{ $siteBaseUrl }}{{.Pre}}{{ .URL }}{{else}}{{.URL | absLangURL}}{{end}}">{{ .Name }}</a>
				</li>
				{{ end }}
			</ul>

How can i access to my custom parameter

Menu configuration does not accept custom parameters.

Not even Hugo 0.79?

1 Like

You are right. @alcarazr
I forgot about it. Menus | Hugo

I suppose that the OP wouls manage to get the custom param but the configuration would probable need to look something like this:

[[Languages.en.menu.main]]
    name = "Home"
    pre = "#"
    url = "home"
    weight = 1
    [menu.main.params]
        useBaseUrl = true
1 Like