Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting defaults for Jekyll collections

Tags:

jekyll

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.

like image 987
Zander Avatar asked Dec 24 '22 22:12

Zander


1 Answers

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"
like image 148
JoostS Avatar answered Dec 26 '22 11:12

JoostS