How to Efficiently Manage Collections with Custom Permalinks in Jekyll?

Hey guys… :wave:

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:

  1. Some pages in the collections do not seem to respect the specified structure. They either end up with the default permalink or break entirely.
  2. Is there a way to automatically generate these without manually adding front matter to every file?
  3. How do these custom permalinks interact with pagination, particularly for the blog collection?

I also check this: https://talk.jekyllrb.com/t/automotive-makes-and-models-a-case-of-nested-collections-and-permalinksalesforce-admin But I have not found any solution. Could anyone guide me about this? If anyone has experience managing this kind of setup or can point me toward any plugins or best practice.

Thanks in advance!

Respected community member!

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.

In our case we have this in our _config.yml:

collections:
  news:
    defaults:
      layout: post
    output: true
    permalink: /:collection/:title/
  projects:
    output: true
    permalink: /:collection/:title/

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.

Now, in the docs it states:

Collections have the following placeholders available

So maybe only those placeholders can be used in the _config.yml? Not sure about that.