Cannot grab second default value


#1

I am trying to grab the value of theme-color from the defaults array, but to no avail. However, I am able to grab the author value.

#####_config.yml:
defaults:
-
scope:
path: ""
values:
author: "ICanGrabThisValueButNotBelow"
theme: “ff3310”
#####template/layout:


#2

Your variable names are different.

In your front matter default you named it theme and in the layout you’re calling theme-color. Name them the same and it should work.


#3

Thanks. I updated the vars and rebuilt. The value is still blank. Anything else to try?


#4

Yes, one obvious thing I missed. You’re setting theme-color as a Front Matter default therefore it is accessible through the page object, not site. So you would use page.theme-color instead.

site.theme-color would be used outside of the Front Matter defaults in your _config.yml, similar to title or url.


#5

OK, that’s it. :slight_smile:So the below would hold true.

Global/Site-level Variables [in _config.yml]

author: "MyNameHere"
theme-color: "#ff3310"

{{ site.theme-color }}

Page-level Variables [also in _config.yml]

defaults:
  -
    scope:
      path: "" # an empty string here means all files in the project
    values:
      theme-color: "ff3310"

{{ page.theme-color }}