Reputation: 151
I'm fairly new to Jekyll, and am currently trying to build a site to hold a bunch of pages containing course training material. I'm trying to use Jeykll collections to do this and have a site structure like this:
/
|
|_ "_course001"
|
|_ subdirs/subdocs
|_ "_course002"
|
|_ subdirs/subdocs
When rendering content for each course (setup as a collection) I would like a navbar to display the other documents in the current course/collection only (i.e. not in other courses).
Using something like this works:
{% for each coursedoc in site.course001 %}
[Create anchors and text]
{% endfor %}
However I want to have the collection name by dynamically assigned during the site build rather than hardcoded. I've tried doing something like this:
{% for each coursedoc in {{ page.collection | prepend: "site." }} %}
[Create anchors and text]
{% endfor %}
But this does not work, I guess because {{ page.collection | prepend: "site." }}
returns a string.
Anyone have some suggestions on how I could do this?
Upvotes: 1
Views: 174
Reputation: 151
And I think I just answered my own question:
{% assign collection = site.collections | where: "label", page.collection | first %}
{% for node in collection.docs %}
[Create anchors and text]
{% endfor %}
Upvotes: 3