Hugo: Inconsistent Handling of .Param Case Sensitivity

Created on 13 Aug 2018  路  1Comment  路  Source: gohugoio/hugo

There is an inconsistency in how Hugo handles capitalized .Params.

Consider the following front matter parameter:

+++
sidebarName = "Introduction"
+++

The name sidebarName is handled differently in various cases:

{{ .Params.sidebarName }}       // This works!
{{ .CurrentSection.Params.sidebarName }}        // This does not work!

See also discussion here: https://discourse.gohugo.io/t/config-params-should-be-all-lowercase-or-not/5051/

As @bep wrote:

All config keys are stored as lower-case to be able to access them with any case.

But it seems if we access them via a section (or maybe other ways?), then this is not true.


Hugo version: v0.46/extended windows/amd64

Bug

Most helpful comment

It's a bug. I think it is registered before, but I haven't gotten time to look into it. It's probably time to do that now ... The thing is, when we made the params all lowercase (for good reason), it created some havoc, so I created an AST template transformer to make .Params.sidebarName into .Params.sidebarname.

Note that {{ .CurrentSection.Param "sidebarName" }} will work as expected.

>All comments

It's a bug. I think it is registered before, but I haven't gotten time to look into it. It's probably time to do that now ... The thing is, when we made the params all lowercase (for good reason), it created some havoc, so I created an AST template transformer to make .Params.sidebarName into .Params.sidebarname.

Note that {{ .CurrentSection.Param "sidebarName" }} will work as expected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ianbrandt picture ianbrandt  路  3Comments

digitalcraftsman picture digitalcraftsman  路  3Comments

chrissparksnj picture chrissparksnj  路  3Comments

arikroc picture arikroc  路  3Comments

VoidingWarranties picture VoidingWarranties  路  3Comments