Pretty new to hugo and are stuck with using a conditional statement.
I am trying to add "active" class in navigation, nav.html, by using {{ if in .Params.title "Snow" }} active {{ end }} but it does not print anything?, I am not using the hugo menu system, see example below.
When modifying it by adding else like {{ if in .Params.title "Snow" }} active {{ else }} dummy {{ end }} it prints out dummy, so the statement seems to be working but it can not find .Params.title "Snow"
The strange thing is that when adding the exact same statement in the footer, footer.html, it just works fine, see example below.
Every *.md file in /content/ (when used in the menu) has it's own section / directory in layout.
/content/snow.md
/content/water.md
/layouts/snow/baseof.html
/layouts/snow/single.html
/layouts/water/baseof.html
/layouts/water/single.html
what am I doing wrong?
The frontmatter of the markdown file snow.md and water.md in /content/
---
title: Snow
---
---
title: Water
---
The layout file nav.html in /layouts/partials/ (using bootstrap for css)
Except for some added images (left out of the code here) baseof and single are the same for snow and water.
baseof.html
{{ partial "meta.html" . }}
{{ partial "hoofd.html" }}
{{ partial "nav.html" }}
{{ block "main" . }}
{{ end }}
{{ partial "footer.html" . }}
single.html
{{ define "main" }}
{{ .Content }}
{{ end }}
When I use the hugo statement in the partial footer.html it works fine...????
© 2025 Woodenart.nl
{{ if in .Params.title "Snow" }} Snow {{ end }}