Reputation: 337
I'm trying to do this because I'm using a CMS where users will be able to edit a data file to make changes to the page instead of the _config.yml. I'm wondering if it's possible to reference a variable from the data file and place this reference within the _config.yml.
Here's an example of what I'm trying to do;
Data File (/_data/site-data.yml)
navigation:
navigation_colour: '#462634'
Config File (/_config.yml)
defaults:
-
values:
navigation:
navigation_colour: site.data.site-data.navigation.navigation-colour
Is something similar to this possible? Thanks!
Upvotes: 3
Views: 2030
Reputation: 1924
Jekyll does not parse variables in _config.yml
. However inside your blog you can use liquid tags like {{site-data.navigation.navigation-colour}}
. See here.
If its mandate to replace variables in _config.yml
then use a custom or standard replacement plugin with grunt. So effective grunt build task will first perform token replacement in _config.yml
and then do jekyll build.
Upvotes: 2
Reputation: 2183
You can assign at least in one config-file variables, I have not tested this over multiple files.
YAML, hello
will become Greetings earthling!
something: &hello Greetings earthling!
myref: *hello
MARKDOWN
{{ site.data.samplelist.myref }}
Upvotes: 1