I have a parameter in the front matter of my pages that should trigger a certain class. Think of a boosted entry that will be displayed different.
How do I access that parameter inside of a menu loop?
Frontmatter of a page:
---
boost: true
---
in the menu partial:
{{ range .Children }}
<a class="dropdown-item {{ with .Params.boost }}bg-secondary {{ end}}" href="{{ .URL }}">
{{ .Title }}
</a>
{{ end }}
I would have expected Hugo to have the params available at this point, but it bails out with:
Failed to render pages:
render of "section" failed:
execute of template failed:
template: _default/list.html:4:12:
executing "_default/list.html" at <partial "header.html" .>:
error calling partial:
execute of template failed:
template: partials/header.html:1:3:
executing "partials/header.html" at <partial "header/navigation.html" .>:
error calling partial: "/.../partials/header/navigation.html:15:57":
execute of template failed:
template: partials/header/navigation.html:15:57:
executing "partials/header/navigation.html" at <.Params.boost>:
can't evaluate field Params in type *navigation.MenuEntry
Debugging the menu items with debugprint.html (Thank you @kaushalmodi) shows that indeed there are not params in the menu entry.