Shows all posts instead of from specific category

<h2 class="category-name">Категорія: Війна</h2>
{% for post in site.categories.war %}
  {% include posts.html %}
{% endfor %}


<div class="post-list">
    {% for post in paginator.posts %}
      <div class="post">
        <h2 class="post-title"><a href="{{ post.url }}">{{ post.title }}</a></h2>
        {% include post-date.html %}
        <p class="post-meta">Категорія: {{ post.categoryalias }}</p>
        <img class="post-thumbnail" src="{{ post.thumbnail }}">
        <p class="post-meta">{{ post.excerpt }}</p>
        <a href="{{ post.url }}" class="post-readmore">Читати далі</a>
    {% endfor %}
  {% if paginator.total_pages > 1 %}
    {% if paginator.previous_page %}
      <a href="{{ paginator.previous_page_path | prepend: site.baseurl }}">Наступна сторінка →</a>
    {% endif %}
    {% if paginator.next_page %}
      <a href="{{ paginator.next_page_path | prepend: site.baseurl }}">← Попередня сторінка</a>
    {% endif %}
  {% endif %}

I’ve done everything and it still renders all posts…
I set categories like categories: [smthng] in the front matter if anything.

are you using jekyll-paginate-v2? it should support category pagination but the original one does not.

1 Like

Yes I do use that plugin

I don’t use pagination so I will be of limited help - but your initial problem is that on the top code section you are checking the category, but then you are including the posts.html file which is just taking all the posts. You need to do the category in the posts.html file also.

If you are re-using the posts.html file maybe make a duplicate of it? or you can pass a parameter in with it I think and then use that in the posts.html to filter by the category.

I’m guessing the plugins docs have examples that should get you fixed up.