I have custom collections for my Jekyll project:
collections_dir: events
collections:
event1:
output: true
permalink: /:collection/:title
sort_by: date
event2:
output: true
permalink: /:collection/:title
sort_by: date
And it’s my directory structure:
project
├── _config.yml
└── events
├── _event1
│ ├── images
│ │ ├── title1.jpg
│ │ └── title2.jpg
│ ├── title1.md
│ └── title2.md
└── _event2
├── images
│ ├── title3.jpg
│ └── title4.jpg
├── title3.md
└── title4.md
- I have two events collection
- Every collection has some docs
- Every doc needs an image
Problem
Currently, I should manually put all images in the assets
folder so I can use them like this /assets/img/event1/title1.jpg
:
project
├── _config.yml
├── events
└── assets
└── img
└── event1
├── title1.jpg
├── title2.jpg
├── ...
└── ...
It’s very hard to manage image assets for every collection because I have many of them. Is there any solution that every collection has its own asset
folder ( Like the first directory tree ) and Jekyll’s build process copies them in the final _site
directory?
Unfortunately, this doesn’t work. Jekyll will pick one image of every extension from every collection, rename it to the collection’s name ( event1.jpg
/ event1.png
) and copy that to the site’s root and return an error message for other ones:
Conflict: The following destination is shared by multiple files.
The written file may end up with unexpected contents.
/<project>/_site/event1.jpg
- /<project>/events/_event1/images/title2.jpg
- /<project>/events/_event1/images/title3.jpg
- /<project>/events/_event1/images/title4.jpg
I don’t understand this behavior. Do you have any idea how to do this?