多页上的 Jekyll 分页 [英] Jekyll pagination on multiple pages

查看:16
本文介绍了多页上的 Jekyll 分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 html/css 的新手,但我正在尝试使用 Jekyll 创建一个博客,我在这里找到了这个主题 https://github.com/rosario/kasper

I am new to html/css but am attempting to create a blog using Jekyll and this theme I found here https://github.com/rosario/kasper

主页 index.html 包含分页列表中的所有帖子.这很酷.但是,我想将我的帖子分为不同的类别,并为每个群组添加一个页面,其中包含该群组帖子的分页列表.

The homepage index.html has the all the posts in a paginated list. This is cool. However i would like to group my posts into different categories and have an additional page for each group which would have a paginated list of just posts of that groups.

我可以创建其他页面,但无法使用 index.html 中的任何类型的代码变体获取列表,但需要指定一个组.

I can create the additional pages but can't get the lists using any sort of variant of the code in index.html but specifying a group.

这可能吗?

推荐答案

如果您想为您的问题提供更详细的答案,您应该将您的代码与您的答案分享.据我所知,您在创建属于同一类别的博客文章列表时遇到了问题.如果这是正确的,那么您可以通过使用液体 for 循环来实现它.如果你查看 index.html 上的代码,它有这个 for 循环

You should share your code with your answer if you want a more detailed answer for your question. As far as I understood you are having trouble with creating a list of blog posts that are all same category. If this is correct then you can achieve it by using liquid for loop. If you look into the code on your index.html it has this for loop

{% for post in paginator.posts %}

如果你像下面这样修改它

If you modify it like below

{% for post in site.categories.comedy %}

其中 comedy 是类别名称.这样我们就可以访问站点对象中的类别并获取该类别下的所有帖子.如果您在不同的页面上放置类似的循环,同时更改类别名称,您可以在不同的页面上拥有不同的类别列表.确保您在帖子的正面内容中正确输入了类别名称.如果我成功回答了您的问题,请将答案标记为正确.

Where comedy is a category name. This way we access the category within the site object and get all the posts under this category. If you place similar loops on your separate pages while changing the category names you can have different category lists on different pages. Make sure that you correctly input the category names in your post's front matter. If I succeeded in answering your question please mark the answer as correct.

这篇关于多页上的 Jekyll 分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆