在Jekyll Collections文档之后,我在_config.yml中编写了以下代码
_config.yml collections: - popular_posts
因此,当我打印{{site.collections}}时,输出为"popular_posts".
我还在"_posts"的同一级别创建了一个名为"_popular_posts"的文件夹._popular_posts包含两个.md文件,其中包含一些YAML前端内容,与帖子相同.
但是,如果我打印{{site.popular_posts}}或{{site.collections.popular_posts}},则没有输出.
如何让Jekyll识别该目录中的.md文件,以便以下代码可以正常工作?
{% for popular_post in site.popular_posts %}{{ popular_post.title }}
{{ popular_post.number }}/5 {% endfor %}
小智.. 5
这很容易!你走在正确的轨道上.在你的_config.yml
:
collections: - popular_posts
这将告诉Jekyll读入所有文件_popular_posts
.
如果您希望这两个文件中的每一个都有相应的输出文件(如_posts
现在的工作方式),您需要将您的更改_config.yml
为:
collections: popular_posts: output: true
这将在生产文件/popular_posts/filename1.html
和/popular_posts/filename2.html
对每个岗位的一页.
收藏只是最近在GitHub页面上,所以如果你在那里尝试,它将失败.
如果您需要,请查看jekyll-help以获得更多帮助!
这很容易!你走在正确的轨道上.在你的_config.yml
:
collections: - popular_posts
这将告诉Jekyll读入所有文件_popular_posts
.
如果您希望这两个文件中的每一个都有相应的输出文件(如_posts
现在的工作方式),您需要将您的更改_config.yml
为:
collections: popular_posts: output: true
这将在生产文件/popular_posts/filename1.html
和/popular_posts/filename2.html
对每个岗位的一页.
收藏只是最近在GitHub页面上,所以如果你在那里尝试,它将失败.
如果您需要,请查看jekyll-help以获得更多帮助!