I would like to use Jekyll to create a manual that contains several chapters, each of which contains several sections, and store each section in a separate Markdown file. I want index.md
to look something like this:
<ol>
{% for chapter in site.chapters %}
<li>
<a href="{{chapter.url}}">{{chapter.title}}</a>
<ol>
{% for section in chapter.sections %}
<li><a href="{{section.url}}">{{section.title}}</a></li>
{% endfor %}
</ol>
</li>
{% endfor %}
<ol>
If each chapter is a Markdown file in _chapters
, and I add the right lines to _config.yml
, I can iterate over the chapters, pull out the title field from the YAML header, etc. Is there a way to nest this? I've tried creating sub-directories under _chapters
with various names, but (a) Jekyll doesn't pick them up as sub-collections and (b) there's no obvious place to store chapter-level information (like the chapter's overall title).
(Note: I think I can do this by explicitly enumerating chapters and sections in a block of YAML in _config.yml
, or by creating a separate YAML file in _data
, but I don't want to have to worry about keeping that enumeration in sync with the actual chapters and sections: I'd like Jekyll to pick up changes automatically.)