I am working on a Jekyll site that uses several collections (e.g., blog posts, case studies, and tutorials), and I want to assign each collection a unique permalink structure. For example:
Blog posts should follow: /blog/:year/:month/:title/
Case studies should follow: /case-studies/:title/
Tutorials should follow: /tutorials/:category/:title/
I have managed to get the basic permalink structures set up in _config.yml, but I’m running into a few issues:
Some pages in the collections do not seem to respect the specified structure. They either end up with the default permalink or break entirely.
Is there a way to automatically generate these without manually adding front matter to every file?
How do these custom permalinks interact with pagination, particularly for the blog collection?
I’d investigate this more to see what is happening. Maybe some pages have a permalink in the frontmatter?
Category and tag are specific to posts - so using them in a permalink might work, but in a normal non post collection they will just be ordinary front matter variables that I don’t think will be available in the permalink.
So if your blog is really a post that permalink should be ok, the second one should be ok as a collection but the 3rd one probably is not possible to have setup to automatically work.
I don’t use permalinks much so don’t take this as the absolute truth, more like a rough guess.
This way we don’t need to manually set the permalink for every item in the collections. We only need to define the specified values, in this case :title as title: project 1 for example.