本文介绍了如何在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中列出同一类别的帖子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 03:41