Page Params got lowercased #2590

Closed
rahulrai-in opened this Issue Oct 17, 2016 · 7 comments

Comments

Projects
None yet
5 participants
@rahulrai-in
Contributor

rahulrai-in commented Oct 17, 2016

I used to have images displayed through a dynamic url e.g.
<img src="{{ .Site.Params.resourcesBaseUrl }}/profilePicture.jpg" class="img-responsive" alt="Profile Picture"/>

This used to work fine until recently. Now Hugo is not able to concatenate the two strings and just outputs image source as /profilePicture.jpg which does not render any images.

I am using the latest build to deploy my website.

@chaseadamsio

This comment has been minimized.

Show comment
Hide comment
@chaseadamsio

chaseadamsio Oct 17, 2016

Contributor

All Params are only accessible using all lowercase characters.

https://gohugo.io/templates/variables/

Have you tried changing .Site.Params.resourcesBaseUrl to .Site.Params.resourcesbaseurl (in both the markdown and the template)?

Contributor

chaseadamsio commented Oct 17, 2016

All Params are only accessible using all lowercase characters.

https://gohugo.io/templates/variables/

Have you tried changing .Site.Params.resourcesBaseUrl to .Site.Params.resourcesbaseurl (in both the markdown and the template)?

@rahulrai-in

This comment has been minimized.

Show comment
Hide comment
@rahulrai-in

rahulrai-in Oct 17, 2016

Contributor

That fixed the issue. However, this is a recently added feature. My site was working fine until my last deployment last month. I hope Hugo maintains backward compatibility and documents breaking changes somewhere.

Contributor

rahulrai-in commented Oct 17, 2016

That fixed the issue. However, this is a recently added feature. My site was working fine until my last deployment last month. I hope Hugo maintains backward compatibility and documents breaking changes somewhere.

@chaseadamsio

This comment has been minimized.

Show comment
Hide comment
@chaseadamsio

chaseadamsio Oct 17, 2016

Contributor

What version did you upgrade from and to? Are you compiling off of master? This particular part of the documentation was last updated January 27, 2015 so it's been this way for a long time: https://github.com/spf13/hugo/blame/master/docs/content/templates/variables.md#L73

Contributor

chaseadamsio commented Oct 17, 2016

What version did you upgrade from and to? Are you compiling off of master? This particular part of the documentation was last updated January 27, 2015 so it's been this way for a long time: https://github.com/spf13/hugo/blame/master/docs/content/templates/variables.md#L73

@chaseadamsio

This comment has been minimized.

Show comment
Hide comment
@chaseadamsio

chaseadamsio Oct 17, 2016

Contributor

@moonytheloony I've left you a github issue on one of your projects Blog-Web with a recommendation of how to install hugo for usage in travisci. Using go get on hugo will get you the latest master and you likely want to use a version of hugo that won't change so you know the API you're working with won't change.

Hope that helps!

Contributor

chaseadamsio commented Oct 17, 2016

@moonytheloony I've left you a github issue on one of your projects Blog-Web with a recommendation of how to install hugo for usage in travisci. Using go get on hugo will get you the latest master and you likely want to use a version of hugo that won't change so you know the API you're working with won't change.

Hope that helps!

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Oct 17, 2016

Member

I will reopen. This lower-casing of Params may have been too breaking -- lets see if we can have both, somehow.

Member

bep commented Oct 17, 2016

I will reopen. This lower-casing of Params may have been too breaking -- lets see if we can have both, somehow.

@bep bep reopened this Oct 17, 2016

@bep bep changed the title from Concatenation has stopped working. to Page Params got lowercased Oct 17, 2016

@bep bep added Bug and removed Bug labels Oct 17, 2016

bep added a commit that referenced this issue Oct 17, 2016

Consolidate the Param methods
Maps in Viper, Hugo's config backing store, is now properly lower-cased not just on top level, the current situation.

While this is mostly a good thing, as you don't need to know the original casing to look up a value, it will be breaking for people doing direct lookups in the ´Site.Params` map.

We will try to find a solution to this "breakage", but the recommended method to get params values is via the `.Param` methods.

This method is now implemented on `Node`, `Page` and `Site` and is case-insensitive:

* Use `.Param "someKey" ` if you want page param with fall back to site param if not found on page.
* Use `.Site.Param "someKey"` to get a site param

See #2590

@bep bep added the Bug label Oct 24, 2016

@bep bep added this to the v0.18 milestone Oct 24, 2016

@bep bep self-assigned this Oct 24, 2016

@sylus

This comment has been minimized.

Show comment
Hide comment
@sylus

sylus Oct 28, 2016

Also ran into this unexpectedly as my Travis deploy of compiled assets to github pages were missing all param attributes. Glad for this issue to know it wasn't a misconfiguration ^_^

sylus commented Oct 28, 2016

Also ran into this unexpectedly as my Travis deploy of compiled assets to github pages were missing all param attributes. Glad for this issue to know it wasn't a misconfiguration ^_^

@remeh

This comment has been minimized.

Show comment
Hide comment
@remeh

remeh Nov 9, 2016

What would you advice for themes maintainers ?

We have the problem with the cocoa theme where we can't support both Hugo 0.17 and Hugo 0.18 because one looks for case sensitive variable in Params and the latter is looking for the lowercased ones.

Maybe changing all the sample config.toml variables to lowercase ?

remeh commented Nov 9, 2016

What would you advice for themes maintainers ?

We have the problem with the cocoa theme where we can't support both Hugo 0.17 and Hugo 0.18 because one looks for case sensitive variable in Params and the latter is looking for the lowercased ones.

Maybe changing all the sample config.toml variables to lowercase ?

@remeh remeh referenced this issue in nishanths/cocoa-hugo-theme Nov 9, 2016

Closed

can't evaluate field Param in type *hugolib.SiteInfo #27

@Sergobot Sergobot referenced this issue in shenoybr/hugo-goa Nov 19, 2016

Merged

Finally fix list, content and avatar templates #10

bep added a commit to bep/hugo that referenced this issue Nov 22, 2016

Fix case issues with Params
There are currently several Params and case related issues floating around in Hugo.

This is very confusing for users and one of the most common support questions on the forum.

And while there have been done some great leg work in Viper etc., this is of limited value since this and similar doesn't work:

`Params.myCamelCasedParam`

Hugo has control over all the template method invocations, and can take care of all the lower-casing of the map lookup keys.

But that doesn't help with direct template lookups of type `Site.Params.TWITTER_CONFIG.USER_ID`.

This commit solves that by doing some carefully crafted modifications of the templates' AST -- lowercasing the params keys.

This is low-level work, but it's not like the template API wil change -- and this is important enough to defend such "bit fiddling".

Tests are added for all the template engines: Go templates, Ace and Amber.

Fixes #2615
Fixes #1129
Fixes #2590

@bep bep closed this in #2630 Nov 22, 2016

bep added a commit that referenced this issue Nov 22, 2016

Fix case issues with Params
There are currently several Params and case related issues floating around in Hugo.

This is very confusing for users and one of the most common support questions on the forum.

And while there have been done some great leg work in Viper etc., this is of limited value since this and similar doesn't work:

`Params.myCamelCasedParam`

Hugo has control over all the template method invocations, and can take care of all the lower-casing of the map lookup keys.

But that doesn't help with direct template lookups of type `Site.Params.TWITTER_CONFIG.USER_ID`.

This commit solves that by doing some carefully crafted modifications of the templates' AST -- lowercasing the params keys.

This is low-level work, but it's not like the template API wil change -- and this is important enough to defend such "bit fiddling".

Tests are added for all the template engines: Go templates, Ace and Amber.

Fixes #2615
Fixes #1129
Fixes #2590

bep added a commit to bep/hugo that referenced this issue Nov 22, 2016

Fix case issues with Params
There are currently several Params and case related issues floating around in Hugo.

This is very confusing for users and one of the most common support questions on the forum.

And while there have been done some great leg work in Viper etc., this is of limited value since this and similar doesn't work:

`Params.myCamelCasedParam`

Hugo has control over all the template method invocations, and can take care of all the lower-casing of the map lookup keys.

But that doesn't help with direct template lookups of type `Site.Params.TWITTER_CONFIG.USER_ID`.

This commit solves that by doing some carefully crafted modifications of the templates' AST -- lowercasing the params keys.

This is low-level work, but it's not like the template API wil change -- and this is important enough to defend such "bit fiddling".

Tests are added for all the template engines: Go templates, Ace and Amber.

Fixes #2615
Fixes #1129
Fixes #2590

bep added a commit that referenced this issue Nov 22, 2016

Fix case issues with Params
There are currently several Params and case related issues floating around in Hugo.

This is very confusing for users and one of the most common support questions on the forum.

And while there have been done some great leg work in Viper etc., this is of limited value since this and similar doesn't work:

`Params.myCamelCasedParam`

Hugo has control over all the template method invocations, and can take care of all the lower-casing of the map lookup keys.

But that doesn't help with direct template lookups of type `Site.Params.TWITTER_CONFIG.USER_ID`.

This commit solves that by doing some carefully crafted modifications of the templates' AST -- lowercasing the params keys.

This is low-level work, but it's not like the template API wil change -- and this is important enough to defend such "bit fiddling".

Tests are added for all the template engines: Go templates, Ace and Amber.

Fixes #2615
Fixes #1129
Fixes #2590

@kakawait kakawait referenced this issue in kakawait/hugo-tranquilpeak-theme Feb 14, 2017

Merged

Releasing 0.2.2-ALPHA #115

tychoish added a commit to tychoish/hugo that referenced this issue Aug 13, 2017

Consolidate the Param methods
Maps in Viper, Hugo's config backing store, is now properly lower-cased not just on top level, the current situation.

While this is mostly a good thing, as you don't need to know the original casing to look up a value, it will be breaking for people doing direct lookups in the ´Site.Params` map.

We will try to find a solution to this "breakage", but the recommended method to get params values is via the `.Param` methods.

This method is now implemented on `Node`, `Page` and `Site` and is case-insensitive:

* Use `.Param "someKey" ` if you want page param with fall back to site param if not found on page.
* Use `.Site.Param "someKey"` to get a site param

See #2590
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment