Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll - Front Matter defaults not working

Using Jekyll 2.5.3, I've tried to set default values in _config.yml (I'm just playing around to get a feel for it right now). I'm trying to set a default layout right now on a site I'm serving locally. I have set --watch and that's working fine. When I set any YAML defaults in _config.yml, Jekyll does not apply the defaults at all.

Here's the config file I'm currently using:

name: jekyll test
description: test server

url: "http://localhost:4000"

markdown: rdiscount
permalink: pretty

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

The default layout is not applied to any page. I've tried with the title as well, with the same result.

My index.md:

---
title: index
----

{{  page.title  }}

My default.html:

<style>
    body {
        background-color: black;
        color: white;
        font-family: "Helvetica", Arial, sans-serif;
    }
</style>

<body>
    {{  content  }}
</body>

The default layout works fine when put into the YAML Front Matter of the index page itself, the main reason I'm looking for this is so I can apply default.html to 404 pages. The other elements in config.yml aren't giving me any trouble. Is there something I've done wrong?

like image 361
user1576628 Avatar asked Jan 18 '26 06:01

user1576628


1 Answers

Fixed it myself - --watch does not listen for changes to files that aren't included in the site itself (namely _config.yml, which is used to generate pages at runtime). To apply changes to the site configuration, I just had to restart Jekyll and feel a little stupid.

Bottom line: I have learned my lesson. If changes don't appear to be saving, turn it off and on again before asking.

like image 80
user1576628 Avatar answered Jan 20 '26 14:01

user1576628



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!