hendramanudinata03
hendramanudinata03

Reputation: 57

How to make subdirectory collections in Jekyll?

I have a Jekyll site and I want to make collections but with subdirectories

For example, I have kind of this structure:

......
_projects/ # "mysite.domain/projects", contains list of available projects (based on these directory)
├── lineageos # "mysite.domain/projects/lineageos"
├── twrp # "mysite.domain/projects/twrp"
└── ungap # "mysite.domain/projects/ungap"

Is there a way to achieve this? I have read the Jekyll collections docs, but I can't understand it all and apply it for this.

Thanks! Let me know if you need more details.

Note: The things that making me confused is config file and markdown/layout structure for this kind of collections. So it will very appreciated if you tell me about this with detail :)

Upvotes: 1

Views: 901

Answers (1)

KargWare
KargWare

Reputation: 2183

You have to include the projects folder in the _config.yml and set the output to true. The sort_by is optional.

The collection folder must start with underscore _ so rename the folder to "_projects" instead of projects.

collections:
  projects:
     output: true
     sort_by: title

See the hint box of the jekyll docu - collections

Be sure to name your directories correctly
The folder must be named identically to the collection you defined in your _config.yml file, with the addition of the preceding _ character.

Upvotes: 1

Related Questions