Jekyll Bootstrap项目在_posts/core-samples /目录中有一个示例博客文章.
我假设子主导中的帖子(文件)的处理方式与根目录中的帖子相同.它是否正确?
如果是这样,我将添加一个"stage"子目录,将其排除,这样我就可以停放帖子并通过移动它们来发布它们.
由于只是不同之处,post.path所以我同意你的说法:
子目录中的帖子(文件)的处理方式与根目录中的帖子相同
您可以将帖子停放在目录中_posts/core-samples/,然后像这样发布它们:
{% for post in site.posts %}
{% if post.path contains 'core-samples' %}
..your code
{% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
作为工作示例,您可能会看到此代码如何在其区域中发布这些停放的帖子。
我最终来到这里是因为我想创建以下结构:
index.html
_animals
cats
my-cat.html
...
dogs
my-dog.html
...
Run Code Online (Sandbox Code Playgroud)
我创建了该结构,然后在_config.yml:
collections:
animals:
output: true
permalink: /animal/:title.html
Run Code Online (Sandbox Code Playgroud)
最后,让狗进来index.html:
<div id='dogs'>
{% for a in site.animals %}
{% if a.path contains 'dogs' %}
<a href='{{ a.url }}'>{{ a.title }}</a>
{% endif %}
{% endfor %}
</div>
Run Code Online (Sandbox Code Playgroud)
注意:这种方法要求包含所有记录的目录(_animals在我的示例中)不能被命名_posts,因为后者是 Jekyll 中的特殊名称。
| 归档时间: |
|
| 查看次数: |
5423 次 |
| 最近记录: |