Zander
Zander

Reputation: 2684

Setting defaults for Jekyll collections

For some reason I am unable to set defaults for my Jekyll collections. I think I have followed the documentation correctly but even setting a default layout is alluding me..

Here's what I got:

collections:
  work:
    output: true
    permalink: /work/:path/

defaults:
  -
    scope:
      path: ""
      type: "posts"
    values:
      layout: "post"
  -
    scope:
      path: "work"
      type: "pages"
    values:
      layout: "work"

My blog post markdown files are in /_posts and my work (collection) markdown files are in /_work. In the example above, I want all work items to use the work collection. How is this not working?

By the way, I am using Jekyll 3.3.1.

Upvotes: 4

Views: 3006

Answers (1)

Mr. Hugo
Mr. Hugo

Reputation: 12592

You are referring to pages that have the path 'work', while you want to refer to all items in the collection 'work'. This can be done by only specifying the 'type' (collection) and leaving the path empty, like this:

collections:
  work:
    output: true
    permalink: /work/:path/

defaults:
  - scope:
      path: ""
      type: "posts"
    values:
      layout: "post"
  - scope:
      path: ""
      type: "work"
    values:
      layout: "work"

Upvotes: 11

Related Questions