This has to be simple. What I want to do is load a partial html file in header.html
depending on a config in config.toml
.
This is in config.toml:
[banner]
This is in header.html:
{{ if .Site.Params.banner }}
{{ partial “banner.html” . }}
{{ else }}
(no banner)
{{ end }}
It doesn’t work. With or without [banner]
in config.toml, I get the output (no banner)
.
Even after restarting Hugo (70) and disabling caching in my browser dev tools. What am I missing?
You’re creating a table. It can’t be empty. In your TOML write:
[params]
banner = true
Go from there.
Thanks! That works with a config within [params]. And I didn’t know what TOML stood for 
I was looking at this page https://gohugohq.com/howto/hugo-isset/ and that’s how I guessed at my first try. That page shows that isset should work for an empty table:
{{ if isset .Site.Params “banner” }}
(banner)
{{ else }}
(no banner)
{{ end }}
But it doesn’t for me. But that page is from 2017, so is it outdated?
In any event, a second, related question: seeing that this works
[params]
banner = true
how would I use a separate param in config.toml? Like
[showbanner]
banner = true
to show/hide the banner with either banner = true or banner = false ?
[showbanner]
banner = true
[showbanner]
banner = false