在Jekyll,我们可以在同一文件夹内的多个集合吗? [英] In Jekyll, can we group multiple collections inside the same folder?
问题描述
在config.yml中,我可以这样定义我的集合:
collections:
music:
输出:false
dancing:
输出:false
将有很多集合,他们会混乱我的根Jekyll文件夹。
有没有办法将所有集合分组到一个文件夹,例如命名_collections? p>
所以,我会有:
_collections
_dancing
_music
....
没有什么能阻止您在集合中使用子文件夹。
(注意:这不是您的问题的答案,但可能的解决方法)
因此,作为解决方法,您可以只有一个集合:say _arts
,并整理您的文件夹,例如:
_arts
dancing
音乐
音乐会
.....
您可以单独使用:
- 文件中的FrontMatter变量
类别:dancing
当您有一个输出,并检查这是一个跳舞的唯一列表为例。
{%for project in site.arts%}
{%if project.category =='dancing'%}
....
{%endif%}
{ %endfor%}
- strong>无输出。
{%for project in site.arts%}
{%if project.url contains'dancing'%}
...
{%endif%}
{%endfor%}
如果你有数以百计的项目,这可能会减慢你的构建。
In config.yml, I define my collections like this:
collections:
music:
output: false
dancing:
output: false
The problem is I will have lots of collections and they will clutter my root Jekyll folder.
Is there a way to group all the collections into a folder, named for example, _collections?
So, I would have:
_collections
_dancing
_music
....
Nothing prevents you to use subfolders in your collection. (Note: this is not an answer to your question but a possible workaround)
So as a workaround you could have just one collection: say _arts
for example and organize your folders like:
_arts
dancing
music
concerts
.....
to list them separately you can use:
- a FrontMatter variable in your files
category: dancing
when you have a output and check this for a dancing only list for example.
{% for project in site.arts %}
{% if project.category == 'dancing' %}
....
{% endif %}
{% endfor %}
- or check the path when you have no output for the collection
{% for project in site.arts %}
{% if project.url contains 'dancing' %}
....
{% endif %}
{% endfor %}
This could slowdown your build if you have hundreds and hundreds of items inside.
这篇关于在Jekyll,我们可以在同一文件夹内的多个集合吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!