Jekyll default not working

Hey, I’m trying to add default layout on my website. When I put it on every pages it works, but when I want to have it only in a specific collection it doesn’t. I saw the same issue here https://talk.jekyllrb.com/t/yaml-front-matter-defaults-not-working/296, I tried to reindent everything but didn’t work. This is my _config.yml:

collections:
  authors:
    default:
      layout: authors
    output: true

defaults:
  -
    scope:
      path: "authors"
    values:
      layout: "authors"
  -
    scope:
      path: ""
    values:
      layout: "default"

Someone has a solution? Thanks!

When you add a layout to the page frontmatter it is overwriting the defaults listed in your config. The config you’ve listed above should be sending everything in the site to the default layout. I think you’ll want something like this:

In the _config.yml you can add layouts for different types, or you could send them to default. In this example I’ve sent them to different layouts:

defaults:
- scope:
    type: posts
  values:
    layout: post
- scope:
    type: pages
  values:
    layout: page
- scope:
    type: authors
  values:
    layout: authors

Then, assuming those layouts need passing along to the default layout, in each layout file you’ll want this:

layout: default

@JulSeb42 The reason your config isn’t working for the authors collection is because the scope.path value is incorrect. Collections have a leading slash. Therefore the dirname should actually be _authors:

defaults:
  - scope:
      path: _authors
    values:
      layout: authors

You could also just use type (which doesn’t have the leading underscore):

defaults:
  - scope:
      type: authors
    values:
      layout: authors

It worked, thanks a lot!