In Jekyll, can we group multiple collections inside the same folder?

前端 未结 4 1059
南旧
南旧 2021-02-15 16:10

In config.yml, I define my collections like this:

collections:
  music:
    output: false
  dancing:
    output: false

The problem is I will ha

4条回答
  •  遇见更好的自我
    2021-02-15 17:04

    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:

    1. 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 %}
      
    2. 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.

提交回复
热议问题