How Jekyll processes messages in _posts / subdir

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

I assume that messages (files) in sub-directories are treated the same as messages in the root directory. Is it correct?

If this is the case, I will add an auxiliary stage directory, excluding it so that I can leave messages and publish them by moving them.

+9
source share
4 answers

Accidentally found it in the post-yaml section :

, . , ​​ . ( ) YAML , .

So ==

+5

post.path :

() directores , diretory

_posts/core-samples/ :

{% for post in site.posts %}
  {% if post.path contains 'core-samples' %}
     ..your code
  {% endif %}
{% endfor %}  

, .

+5

In fact, what this statement says, you need to put the _posts folder inside a subdirectory. And then this subdirectory will be considered as a category.

+1
source

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 this structure, then in _config.yml:

collections:
  animals:
    output: true
    permalink: /animal/:title.html

Finally, to get only 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 entries ( _animalsin my example) cannot be named _posts, since the latter is a special name in Jekyll.

0
source

All Articles