我已经实现了this example-site ,这不是一个真正的网站,只是一个例子,我在网站的右侧列出了类别,它们实际上是页面,每个页面都是一个类别(没有为此使用的插件)。
他们不会使用标准方法查询帖子,如下所示
{% for post in site.categories %}
{{the post}}
{ endfor }
但是在每个页面(类别)中都是这样,我循环如此
{% 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 %}
我这样做是因为正如 jekyll 文档中所写,分页无法通过标签或类别查询帖子
- 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. *
我想如果每个类别(在这种情况下每个页面 - index.html)都有自己的index.html,我可以对类别进行分页,但不幸的是我不能。
主页分页如您所见
我不想为此使用插件,因为所有诸如“通过标签相关帖子”,“每个帖子类别链接到其类别页面”,以及我在没有插件的情况下所做的其他事情,因此可以直接编写帖子来自 github。
如何对类别的帖子进行分页?
在源代码中,有文件夹类别,这里 - 其文件夹中的每个类别
最佳答案
目前还不能。
如果你想让它工作,你需要为此创建一个插件。我使用纯 jekyll(无插件)构建了相当多的模板,这是您无法绕过的限制之一。
关于github - Jekyll 为类别帖子分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20600248/