Search code examples
jekyll

Jekyll permalinks based on layout


I'm working on my first Jekyll website, and I'm expecting to have a bunch of different things there such as blog posts, a linked list, photo albums, and so on, and have thus prepared a whole bunch of layouts to suit each of them.

So I was wondering if there was a way I could get Jekyll to set permalinks based on the layout, so that posts have their permalink automatically set to /layout_name/yy/mm/post_name.

I've been digging around Jekyll's permalink documentation and various Jekyll tutorials, but to no avail, and now I'm wondering if it's even possible to automate this.

Any help will be greatly appreciated, thanks!


Solution

  • Following the principle that each type of page/post can be in a specific folder (eg: /albums for you photo albums), you can have a look at default configuration.

    This can help you to set default permalink for a folder in _config.yml :

    defaults:
      -
        scope:
          path: "albums" 
          type: "posts"
        values:
          permalink: "my/albums/"