3
votes

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?

2
This is strange. Can you push your code to github ? - David Jacquel
I was just about to but it looks like relaunching the server fixed it. I'm not sure what was happening, I'll try investigating a little more. - user1576628
Found it, and it was obvious and I should have known. Posting a solution. - user1576628
kind of post mortem duplicate: stackoverflow.com/questions/32281093/… - cregox

2 Answers

5
votes

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.

0
votes

I had this issue. There was an extra space after toggling a comment '#' tag in the frontmatter of my index.md:

---
#title: index
 title: index2
----

and I fixed it by removing the space:

---
#title: index
title: index2
----