I'm trying to build a jekyll site that can generate a page for every data file.
Say we have
/_data/
a.yaml
b.yaml
where
a.yaml
has
event_name: A
time: yesterday
contents:
- name: A1
url: a1
- name: B1
url: b1
b.yaml
is basically the same thing with different contents.
I would like the rendered site to have 2 pages: /a.html
and /b.html
. The contents of each page is a simple listing of the contents in a.yaml
or b.yaml
. Is it possible in current Jekyll?
I know there is a very nice jekyll addin called jekyll-datapage-gen. However, that addin generates pages for every item in a data file and is different from what I'm looking for... Can anyone provide some suggestions here? Thank you!
You can achieve that using Collections instead of data files. Files will look the same, with front matter, and then you specify in the configuration to make each file a different late with output: true
Have a look at https://jekyllrb.com/docs/collections/, your configuration will look like:
collections:
my_collection:
output: true
It is possible to make the same with data files, creating the post a and the post b, and iterating in each page one of the data files, anyway I think using collections fits perfectly in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With