Reputation: 340
I am using Jekyll to build a web site,
I want to have some folder structure like
root
- _posts
Kinds of MD files
Index.html
- v1.0
- _posts
Kinds of MD files
Index.html
I want to build a web site, the URL like http://host/root/ points to current version document,the URL like http://host/root/v1.0 points to version 1.0 document.
In both index.html, I use code like below,
{% 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 %}
The issues I met is,
As both _post folder has similar posts and category, in the http://host/root/, each post is shown twice.
In URL http://host/root/, it has an additional category which contains all the posts (in both folder _posts and v1.0/posts)
The same issues for URL http://host/root/v1.0
I want to know how I can restrict the site.categories to only search specified folder? Or there is some other suggestions on this?
thanks
Upvotes: 0
Views: 123
Reputation: 1377
posts
can not be limited to a particular folder as it is site wide. You can create custom collection
. Suppose if you have v1, v2 and root(pointing to v2). You can use the same collection name for v2 and root.
Upvotes: 1