1
votes

I have implemented this example-site, it's not a real site, just an example, I did categories list in the right side of the site, they're actually pages, every one as one category (there was no used plugins for this).

they don't query posts with standart method, like bellow

{% for post in site.categories %}
   {{the post}}
{ endfor }

BUT like this in every page (category) I loop so

{% for post in site.posts %}


{% assign cat = page.title %}

{% assign post_cat = post.categories | join: '-' %}

{% if post_cat contains cat %}
    here goes the posts...
{% endif %}


{% endfor %}

I did so, because as written in jekyll's documentation, pagination can't work with quering posts via tags or categoires

  • Pagination does not support tags or categories Pagination pages through every post in the posts variable regardless of variables defined in the YAML Front Matter of each. It does not currently allow paging over groups of posts linked by a common tag or category. *

source

I thought if every category (in this case every page - index.html) has its own index.html, Ican paginate categories, but unfortunately I can't.

In home page paginations works as you can see

here is the site

here is the site's source

I don't want use plugin for this, because all things like "related posts via tags", "every post categories linked to its categories page", and the other things I did without plugins, and so can write posts directly from github.

How can I do pagination for the categories' posts ?

In source there are in the folder categories and here - every category in its folder

2

2 Answers

4
votes

Currently, you can't.

You need to create a plugin for that if you want it to work. I've built quite a lot of templates using pure jekyll (without plugins), and this is one of the limitations that you can not get around.

0
votes

Thank you very much for the limitation clue.

As as a workaround to the plugin I created a specific layout listing pages for a category. Applying the layout to static pages created for important categories is slight pain to avoid writing a plugin. Finally I just had to create links between post categories and page using a category layout.