This is partially true because we can’t access variables in template like {{ if isset .Site.Params "fooBar" }}.
But this is accessible by {{ if .Site.Params.fooBar }}.
Is this a bug or spec that {{ if isset .Site.Params "fooBar" }} is not available?
{{ if .Site.Params.fooBar }} should be used for this case?
Maybe the document is kind of confusing for people like me.
You are right about the documentation part, and you are right about the isset part, but we should fix that (I have created an issue). All config keys are stored as lower-case to be able to access them with any case.
As to isset, I believe this is a better construction in most cases:
{{ with .Site.Params.fooBar }}
{{ . }}
{{ end }}
``
I have a question that follows from this and I’m not sure if it’s a bug or expected behaviour so I thought I would post here first.
I am use page-level params as well, and came across an issue where page params are case sensitive if referenced explicitly, but must be lowercase if referenced in a new context via the with construction.
For example, if my YAML front-matter looks like this
mySection:
featureOne: text here
featureTwo: more text here
I can easily reference these params in my template via {{ .Params.mySection.featureOne }}. Notice the case-sensitivity. However, if I use the with construction, I’ve found that I can no longer use camelCase to reference the sub-params, for example:
{{ with .Params.mySection }}
{{ .featureone }} // this works
{{ .featureOne }} // this does not
{{ end }}
Is this expected behavior? I understand not wanting custom params to start with a capital letter as that is “reserved” for hugo’s variables, but it doesn’t make sense to be entirely case-insensitive, right?
To answer the original question you can use snake_case for your custom param keys. In doing so you’ll never have to worry about case, they’re always clearly read and they’re easy to distinguish from what is not custom.
Also since this is an old topic I am archiving it.
We actively discourage people from posting in old threads. Whenever you encounter a problem please open a new thread instead of posting a reply to a very old one. Hugo is in active development and old topics may contain outdated info.