Config Params should be all lowercase or not?


I am a theme developer and have a question about Hugo templates.

I believe config variables of Hugo are case insensitive.
It looks there were problems in the past but they seem fixed.


But there is a confusing situation about this:

Official document says “All Params are only accessible using all lowercase characters.”

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 }}.

  1. 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?
  1. 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 }}

Thank you @bep !
I’ll consider to use {{ with .Site.Params.fooBar }} syntax.

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

    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?

I’ve created an issue for Inconsistent Handling of .Param Case Sensitivity

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.

1 Like

I see that this issue is marked as closed:

But i just ran into it again, and outlined my experience here:

I was banging my head against the wall until someone suggested changing my custom parameter from camelCase to all lower case.

Is it ‘officially’ advised that custom params be written only in lower case?

No this is not the same issue.

Camel case parameters work fine in most cases.

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.