Jekyll - YAML Front Matter Defaults not working

2019-08-12 17:23发布

问题:

I have a multi-site Jekyll project with folders for each site, slc, and la.

However, my YAML Front Matter defaults are not working. None of the default values--including the layout, crucially--are being transmitted to my templates:

//config.yml:

defaults: 
  -
    scope:
      path: "la"
    values:
      layout: "default-la"
      title: "Store Title"
      email: "email@gmail.com"
      baseurl: "" # the subpath of your site, e.g. /blog/
      url: "http://url.com"

// Folder structure

├───assets
│   ├───images
│   └───js
├───css
│   ├───bootstrap
│   │   ├───css
│   │   ├───img
│   │   └───js
│   └───font
├───la
│   ├───assets
│   │   └───images
│   └───css
│       └───css
│           ├───bootstrap
│           │   ├───css
│           │   ├───img
│           │   └───js
│           └───font
├───slc
├───vendor
│   └───js
├───_includes
├───_layouts
├───_sass

// _layouts/default-la.html

<!DOCTYPE html>
<html>

  {% include head.html %}

  <body>

    {% include header-la.html %}

    <div class="page-content">
      <div class="wrapper">
        {% include menu-la.html %}
        {{ content }}
      </div>
    </div>
    {% include js.html %}
    {% include footer-la.html %}

  </body>

</html>

//la/index.html

<div class="home">
    STUFF
</div>

回答1:

Add a front matter to la/index.html

---
---
<div class="home">
    STUFF
</div>

Now your default settings will apply.