0

我的项目结构:

/_config.yml
./_layouts
./_posts
./_posts/2011-07-29-my-first-jekyll-post.markdown
./_notices/2011-07-29-my-first-notice.markdown
./_notices/2011-07-30-my-second-notice.markdown
./_site
./index.html

使用后它可以工作:

{% for post in site.posts %}
 ... listing all posts ...
{% endfor %}

新闻不起作用:

{% for notice in site.notices %}
 ... listing all notices ...
{% endfor %}

通知不起作用。如何实现类似于帖子列表的项目列表?

4

1 回答 1

2

默认情况下,只有_posts文件夹包含可迭代项。如果您使用最新版本的 Jekyll,则可以使用新的集合功能。在您的示例中,将以下内容添加到您的_config.yml

collections:
  - noticies

但请注意,此功能处于早期开发阶段,在稳定之前可能会发生变化。另外,为了记录,notice 的英文复数是notices。

于 2015-03-11T14:29:32.740 回答