vlfl
February 23, 2017, 6:19pm
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:
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.
vlfl
February 23, 2017, 7:59pm
3
vlfl:
theme-color
Thanks. I updated the vars and rebuilt. The value is still blank. Anything else to try?
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
.
1 Like
vlfl
February 23, 2017, 9:49pm
5
OK, that’s it. 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 }}
1 Like