Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll config.yml did not find expected key while parsing a block mapping

Tags:

yaml

jekyll

I'm getting this error in the command line terminal:

did not find expected key while parsing a block mapping at line 18 column 7

My jekyll _config.yml YAML file looks like this:

title: Oliver Williams - Portfolio
url: "http://yourdomain.com" # the base hostname & protocol for your site

# Build settings
markdown: kramdown
permalink: /:title

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

       -
    scope:
      path: "" # an empty string here means all files in the project
      type: "pages" 
    values:
      layout: "page"
like image 401
Ollie_W Avatar asked Oct 11 '15 14:10

Ollie_W


2 Answers

I'm not sure of your formating/indentation for _config.yml.

This one is correct :

title: Oliver Williams - Portfolio
url: "http://yourdomain.com"
markdown: kramdown 
permalink: /:title

defaults: 
  - 
    scope: 
      path: "" 
      type: "posts" 
    values: 
      layout: "post"
  -
    scope:
      path: ""
      type: "pages" 
    values:
      layout: "page"
like image 155
David Jacquel Avatar answered Nov 07 '22 16:11

David Jacquel


The problem is in your second list element for defaults. The marker is indented too much, possible because you used a tab instead of a two spaces.

There is no reason to put the mappings that are elements of those lists on a separate line. You also don't have to indent list elements if the list is a mapping value. Nor is it necessary to quote simple scalars like "posts", "page", etc. (You don't have that for your title value either)

So you can do:

title: Oliver Williams - Portfolio
url: http://yourdomain.com   # the base hostname & protocol for your site

# Build settings
markdown: kramdown
permalink: /:title

defaults:
- scope:
    path: ''         # an empty string here means all files in the project
    type: posts      # previously `post` in Jekyll 2.2.
  values:
    layout: post
- scope:
    path: ''         # an empty string here means all files in the project
    type: pages
  values:
    layout: page

which is equivalent to your input (corrected for the overindented -)

like image 6
Anthon Avatar answered Nov 07 '22 17:11

Anthon