How does Jekyll treat posts in _posts/subdir
Accidentally found it in the post - yaml section:
Instead of placing posts inside of folders, you can specify one or more categories that the post belongs to. When the site is generated the post will act as though it had been set with these categories normally. Categories (plural key) can be specified as a YAML list or a space-separated string.
So sub directories == categories
I ended up here because I wanted to create the following structure:
index.html
_animals
cats
my-cat.html
...
dogs
my-dog.html
...
I created that structure, then in _config.yml
:
collections:
animals:
output: true
permalink: /animal/:title.html
Finally, to get just the dogs in index.html
:
<div id='dogs'>
{% for a in site.animals %}
{% if a.path contains 'dogs' %}
<a href='{{ a.url }}'>{{ a.title }}</a>
{% endif %}
{% endfor %}
</div>
NB: that this approach requires that the directory containing all the records (_animals
in my example) can't be named _posts
, as the latter is a special name in Jekyll.
Actually what that statement says is to put _posts folder inside a sub directory. And then that sub directory will be treated as category.
As the different is only on post.path
so I would agree to your statement:
posts(files) in sub directores are handled the same way as posts in the root diretory
You can park your posts in the directory _posts/core-samples/
and publish them like this:
{% for post in site.posts %}
{% if post.path contains 'core-samples' %}
..your code
{% endif %}
{% endfor %}
As a working sample you may see how this code publish these parked posts in their section.