I would like to organise my collection in the same way as posts with year/month/day URLs. How do I do that?
looks like the date info is not available on non-post files. But I would make sure by adding a front matter variable for date and see if it works.
It would be a bit of a pain but you could specify the exact url in each files front matter permalink.
OK. I have added a date to the front matter. But, like with posts I would like to have a file name like …/yyyy-mm-dd-title.md automatically converted to a /yyyy/mm/dd/title.html URL. Is that behaviour baked in posts or can it be switched on for collections too?
yeah, I didn’t think that would work the docs say it only works on posts but it was worth a check.
My guess is you can only do it if you use the front matter permalink variable and write it exactly as you want it for each one.
Ah okay. So I could use permalink defaulting in _comfig.yml to achieve this?
You’ll have to set a permalink on each collection document, don’t think you can do a default in _config.yml
. Collection documents have no concept of dates, that only works with _posts
.
So you’ll need to manually set the permalink in a collection document’s YAML Front Matter.
For example if you have a collection document of _recipes/chocolate-chip.md
with a date of 2019-08-06
you’d add the following to it’s YAML Front Matter:
permalink: /2019/08/06/chocolate-chip.html