如何在Jekyll中列出同一类别的帖子? [英] How do I list posts from the same category in Jekyll?

查看:40
本文介绍了如何在Jekyll中列出同一类别的帖子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想列出与当前帖子相同类别的固定数量的最新帖子.这是我到达的:

I’d like to list a fixed number of recent posts having the same category as the current post. This is what I have arrived at:

{% for category_name in page.categories limit:1 %}
    <h2>Other articles in {{ category_name }}</h2>
    <ul>
        <!-- now what? -->
    </ul>
{% endfor %}

我了解site.categories,但是我不知道如何对字典进行下标.显然,site.categories.category_name是从字面上获取的,正在寻找一个名为"category_name"的类别.

I know about site.categories, but I don’t know how to subscript the dictionary. Obviously, site.categories.category_name is taken literally, looking for a category named "category_name".

推荐答案

{% for post in site.categories[category_name] %}
    <li>{{ post.title }}</li>
{% endfor %}

这篇关于如何在Jekyll中列出同一类别的帖子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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