In config.yml, I define my collections like this:
collections:
music:
output: false
dancing:
output: false
The problem is I will ha
This is now possible since this issue was merged.
User configures as:
collections_dir: my_collections
Then we look in my_collections/_pizza for the pizza collection, and my_collections/_lasagna for the lasagna collection.
This is now possible (I'm running Jekyll 3.7.2, I'm not sure in which version this was implemented).
Here's how to do it: In your _config.yml
you can define your collections as well as the folder for your collections. Let's take a look at an example on a client site I'm working on:
collections:
events:
output: true
work:
output: true
jobs:
output: true
cases:
output: true
permalink: /work/:name
collections_dir: pages
The collections_dir: [your_folder_here]
will tell Jekyll to look into that folder for collections. My folder structure in development is as follows:
pages/
...
_events/
_work/
_jobs/
_cases/
And in the compiled site it's as follows:
...
events/
jobs/
work/ (contains both "work" and "cases" collections)
One thing also that wasn't asked, but I found to be useful, was that you're able to output different collections into a same folder. In my case I had a client website on which there were two types of work samples: client cases and general examples. We wanted to separate them for better maintenance but also show them in the same folder. To achieve this you can simply define a permalink for the collection. In our case we put permalink for the cases to appear in the work
folder (permalink: /work/:name
).
Hope this helps!
This is also present in the Jekyll documentation
Answer is no. Your collections folder must be at the root of your root folder.
Even if you name you create a collection in _collections/_music folder, and set it up like this :
collections:
collections/_music folder:
output: true
Jekyll ends up looking for your collection in _collections_music folder
(without any slash) because of path sanitize process.
See jekyll code in collection.rb, site.rb and jekyll.rb
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.