How all collections inside one subdirectory works?

As suggested here, I want to use all my collections inside a subdirectory. I wanted to test this feature by putting this inside my _config.yml file:

collections:
  collections_dir: mycollections
  output: true
  permalink: /:name

then I have mycollections subdirectory as follows:

mycollections
...._book
........sample.md

However this file isn’t rendered in my jekyll.

What does the rest of your collection configuration look like? What you have above isn’t enough.

My understanding is all collections_dir is allowing you to do is to place all your collections in a subfolder. So instead of:

my-project/
β”œβ”€β”€ _collection1/
β”‚   β”œβ”€β”€ some-file.md
β”‚   └── another-file.md
β”œβ”€β”€ _collection2/
β”‚   β”œβ”€β”€ 2-some-file.md
β”‚   └── 2-another-file.md
β”œβ”€β”€ _collection3/
β”‚   β”œβ”€β”€ 3-some-file.md
β”‚   └── 3-another-file.md

You can clean things up with:

my-project/
β”œβ”€β”€ mycollections/
β”‚   β”œβ”€β”€ _collection1/
β”‚   β”‚  β”œβ”€β”€ some-file.md
β”‚   β”‚  └── another-file.md
β”‚   β”œβ”€β”€ _collection2/
β”‚   β”‚  β”œβ”€β”€ 2-some-file.md
β”‚   β”‚  └── 2-another-file.md
β”‚   β”œβ”€β”€ _collection3/
β”‚   β”‚  β”œβ”€β”€ 3-some-file.md
β”‚   β”‚  └── 3-another-file.md

That said you still need to configure each collection as you normally would by setting each to output: true and whatever permalinks you want. What you have above looks to be trying to apply a default config to all collections, which I don’t think Jekyll currently supports.

collections:
  collections_dir: mycollections
  collection1:
    output: true
    permalink: /:name
  collection2:
    output: true
    permalink: /:name
  collection3:
    output: true
    permalink: /:name 

Ok so I changed my _config.yml to the following

collections:
  collections_dir: mycollections
  book:
    output: true
    permalink: /:name

but still my collections aren’t rendered. The interesting part is that if I remove _ from _book, the markdown files are treated normally like a page. So I think the collections_dir isn’t configured properly yet? :thinking:

Have you already used this feature successfully? If not I think maybe there is a bug out there.

Nope. Haven’t used collections_dir yet. Seeing how it’s not officially released wouldn’t surprise me if there’s issues with it.

Your best bet is to file a ticket on jekyll/jekyll.

1 Like

I think there’s an error in the official docs… from the souce code it looks like collections_dir is a top-level key instead of being nested within collections object…
So, if your Gemfile is pointed towards the jekyll repo master, then change your config file to following and try again…

collections_dir: mycollections
collections:
  collection1:
    output: true
    permalink: /:name
  collection2:
    output: true
    permalink: /:name
  collection3:
    output: true
    permalink: /:name 
2 Likes

Yes. Thank you very much for your help.