Multiple _posts directories for different collections? - SOLVED


I found a comment via Googling that this is possible but I am stuck - the suggestion was to put the new _posts under a new dir eg “articles”. I have:

  • created the the new dirs
  • put an item in “articles/_posts”
  • copied blog.html to articles.html and edited it appropriately

but I am having problems with the iteration - this doesn’t work:

{% for post in site.articles.posts %}
<div class="post-area">
  <a href="{{ post.url | prepend: site.baseurl }}" class="bold">{{ post.title }}</a>
  <p class="post-date">{{ | date_to_long_string }}</p>
    {{ post.content | strip_html | truncatewords: 50 }}
{% endfor %}

I have tried variations of “{% for post in site.articles.posts %}” but can’t get it to work - I presume it is something simple?


1 Like

I worked it out finally - I needed to set up the collections block in _config.yml . . doh!

Could you please share the conf you added into _config.yml?

If you want for example to set a projects collection under _projects/, add this to your _config.yml:

    output: true
    permalink: /projects/:path/

Sorry about the slow reply - yes, @george-gca is correct . .