Reputation: 64236
I have a data file which is being used inside a Jekyll template:
/{project}/_data/mydata.json
I also want this data to be available on the live website from a JavaScript:
/{project}/_site/mydata.json
Somehow I want one of the following:
Automatically copy itself from "_data" to "_sites" whenever changes are made.
Have the template read the data file from /{project}/mydata.json
since this file will already get copied to the "_sites" folder.
What is the easiest way to maintain a single version of the data file inside both Jekyll templates and JavaScripts?
Upvotes: 2
Views: 370
Reputation: 52829
File /{project}/mydata.json
---
layout: null
---
{{ site.data.mydata | jsonify }}
With jekyll serve
or on github, this will be updated each time your /{project}/_data/mydata.json
is updated.
Et voilà !
Upvotes: 4