Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Jekyll treat posts in _posts/subdir

Tags:

jekyll

The Jekyll Bootstrap project has a sample blog post in the directory _posts/core-samples/ .

I assume, posts (files) in sub directories are handled the same way as posts in the root directory. Is this correct?

If so, I will add a "stage" sub directory, exclude it, so I can park posts and publish them by moving them.

like image 589
citykid Avatar asked Mar 07 '13 18:03

citykid


1 Answers

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.

like image 154
duhaime Avatar answered Oct 11 '22 14:10

duhaime