Joshua Cox

Techromancer

Jekyll Default Configs

Dec 02, 2015

Let’s add some default configs to jekyll so that when people add a new post without the YAML front matter it will still get a default layout etc

Scope

First there is the path portion of the scope we are going to leave this one wide open

    path: "" # an empty string here means all files in the project

Then we will restrict to posts

    type: "posts" # previously `post` in Jekyll 2.2.

Values

Then you’ll need to add in some default values this is what you usually put in your YAML front matter, I set a default layout of post, I set disqus to true to include commenting, and I set the category and tags to default to ‘blog’

  layout: "post"
  disqus: true
  category: blog
  tags:
    - blog

Final Config

Here is the final default config I am using for this site

  defaults:
    -
      scope:
        path: "" # an empty string here means all files in the project
        type: "posts" # previously `post` in Jekyll 2.2.
      values:
        layout: "post"
        disqus: true
        category: blog
        tags:
          - blog

for more in-depth documentation refer to the Jekyll Configuratio docs

Share this post