Reputation: 566
I am making a simple jekyll blog and I have different categories of posts which hold different articles. At some places in my blog I want to display only the articles from that specific category. I keep my categories seperated in my _posts
folder example:
---_posts
|
|-- category1
|-- category2
Inside my _posts folder I just have a folder for each category that keeps my articles. How can I display only the posts which are in catergory1 and category2, something like this:
{% for post in caregory1.posts limit: 2 %}
<div class="center-column">
<article>
<img src="../assets/images/test-img.jpg" alt="" class="test-img">
<p>12.12.2015</p>
<h1>Title</h1>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorum voluptates aperiam, repellendus est eius debitis
suscipit consequatur iure et sequi ipsum eos culpa, delectus magnam amet explicabo! Voluptatem, adipisci quam.</p>
</article>
Upvotes: 1
Views: 168
Reputation: 5434
Jekyll derives categories from a post's superdirectory.
Therefore instead of having _posts/category1
, etc, organize into category1/_posts
, category2/_posts
, etc.
Then iterate through site.categories.category1
to render individual posts:
{% for post in site.categories.category1 %}
<h2>{{ post.title }}</h2>
// insert your code
{% endfor %}
Upvotes: 1