How all collections inside one subdirectory works?


#1

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.


#2

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 

#3

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.


#4

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.


#5

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 

#6

Yes. Thank you very much for your help.