I encountered a case-sensitivity issue with the index
template function using Hugo v0.29: I define site parameter and key names in the config file using camel-case capitalization — e.g., a paramName
parameter with a paramKey
key. I can use the following syntax in templates and shortcodes to directly access the parameter key using the original camel-case capitalization:
{{ $.Site.Params.paramName.paramKey") }}
But if I use the camel-case key capitalization in a call to the index
function in my shortcode, the function fails to locate the key:
{{ (index $.Site.Params.paramName "paramKey") }}
Passing an all-lower-case version of the key name to index
works:
{{ index $.Site.Params.paramName "paramkey" }}
This can also be done by using the lower
function:
{{ index $.Site.Params.paramName (lower "paramKey") }}
(In v0.25 of Hugo, the direct access also seems to support only all-lower-case key parameters.)
–> Is this a known issue, and are there any plans to change this behavior?
I would prefer to use camel-case capitalization in parameter-key names. However, it’s more important to me to use the same capitalization consistently throughout the code, and I also want to avoid extra function calls (using lower
), so for now, I opted to use all lower-case parameter key names with underscores.