【发布时间】:2016-07-19 05:26:49
【问题描述】:
我正在使用 Jekyll 构建一个网站,
我想要一些类似的文件夹结构
root
- _posts
Kinds of MD files
Index.html
- v1.0
- _posts
Kinds of MD files
Index.html
我要建一个网站,http://host/root/这样的URL指向当前版本的文档,http://host/root/v1.0这样的URL指向1.0版本的文档。
在两个 index.html 中,我都使用如下代码,
{% assign sortedCategories = site.categories | sort %}
{% for category in sortedCategories %}
<h1 class="post-title" id="{{ category[1] | replace:' ','-' | replace:'.','' }}">{{ category[1] | join: "/" | upcase }}</h1>
<ul class="post-list">
{% for posts in category %}
{% for post in posts reversed %}
{% if post.title != null%}
<li>
<h2 class="post-title" id="{{ post.id | remove_first:'/'}}">{{ post.title }}</h2>
<article class="post-content">
{{ post.content }}
</article>
</li>
{% endif %}
{% endfor %}
{% endfor %}
</ul>
{% endfor %}
我遇到的问题是,
由于两个 _post 文件夹都有相似的帖子和类别,在 http://host/root/ 中,每个帖子显示两次。
在 URL http://host/root/ 中,它有一个包含所有帖子的附加类别(在文件夹 _posts 和 v1.0/posts 中)
URL http://host/root/v1.0 的相同问题
我想知道如何将 site.categories 限制为仅搜索指定的文件夹?或者对此有什么其他的建议?
谢谢
【问题讨论】:
标签: jekyll categories