New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The global var `site` does not work for mixed-case Params #5615

Closed
kaushalmodi opened this Issue Jan 17, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@kaushalmodi
Copy link
Member

kaushalmodi commented Jan 17, 2019

The bug is as the title says.

Here's a minimum working example:

config.toml

baseURL = "http://example.org/"
languageCode = "en-us"
title = "global site var bug"
theme = "test-theme"

[Params]
  # recognized by Hugo
  mainSections = ["posts", "notes"]
  # my custom param
  feedSections = ["posts"]

index.html

{{ printf `site.Title = %#v <br>` site.Title | safeHTML }}
{{ printf `$.Site.Title = %#v <br><br>` $.Site.Title | safeHTML }}

{{ printf `site.Params.mainSections = %#v <br>` site.Params.mainSections | safeHTML }}
{{ printf `$.Site.Params.mainSections = %#v <br><br>` $.Site.Params.mainSections | safeHTML }}

{{ printf `site.Params.feedSections = %#v <br>` site.Params.feedSections | safeHTML }}
{{ printf `$.Site.Params.feedSections = %#v <br>` $.Site.Params.feedSections | safeHTML }}

Above prints:

site.Title = "global site var bug" 
$.Site.Title = "global site var bug" 

site.Params.mainSections = []interface {}{"posts", "notes"} 
$.Site.Params.mainSections = []interface {}{"posts", "notes"} 

site.Params.feedSections = 
$.Site.Params.feedSections = []interface {}{"posts"} 

Note that site.Params.feedSections doesn't return the expected value.

@kaushalmodi

This comment has been minimized.

Copy link
Member Author

kaushalmodi commented Jan 17, 2019

Here's a repo with the above minimum workable example: https://gitlab.com/hugo-mwe/hugo-issue-5615/

  1. Clone the repo
  2. cd to the dir
  3. Run hugo

And you will get:

image

@bep bep changed the title The global var `site` does not work for custom site Params The global var `site` does not work for mixed-case Params Jan 18, 2019

@bep bep added the Bug label Jan 18, 2019

@bep bep added this to the v0.54 milestone Jan 18, 2019

@bep

This comment has been minimized.

Copy link
Member

bep commented Jan 18, 2019

A bug, alright, but I'm pretty sure that:

site.Params.mainsections

Would work.

@kaushalmodi

This comment has been minimized.

Copy link
Member Author

kaushalmodi commented Jan 18, 2019

A bug, alright, but I'm pretty sure that:

site.Params.mainsections

Would work.

site.Params.mainSections (internal param) already works.

Let me try site.Params.feedsections (custom param) ..

@kaushalmodi

This comment has been minimized.

Copy link
Member Author

kaushalmodi commented Jan 18, 2019

I confirm that the mixed case is not supported only for the custom parameters:

image

bep added a commit to bep/hugo that referenced this issue Jan 20, 2019

bep added a commit to bep/hugo that referenced this issue Jan 20, 2019

@bep bep closed this in #5626 Jan 20, 2019

bep added a commit that referenced this issue Jan 20, 2019

@bep bep modified the milestones: v0.54, v0.53.1 Feb 1, 2019

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