maisagent maisagent - 4 months ago 30
YAML Question

cant find the error in jekyll... "did not find expected key while parsing a block mapping"

I'm a relative newbee to jekyll and liquid. I had this running a while ago but messed it up somehow, without a backup. When finding something the error just shifts to somewhere else... Please take a look.

Here is my code:

---
title: Gallery
layout: gallery
heroimage: /img/hero-image-gallery.jpg
imgsize: small
masonry:
itemsize: 33.333%
categories:
- Objects
- People
- Places
images:
- title: one
thumb: img/gallery-image-one.jpg
big: img/gallery-image-one.jpg
categories:
- People
- Places
- title: two
thumb: img/gallery-image-two.jpg
big: img/gallery-image-two.jpg
categories:
- Objects
- Places
- title: three
thumb: img/gallery-image-three.jpg
big: img/gallery-image-three.jpg
categories:
- People
- title: four
thumb: img/gallery-image-four.jpg
big: img/gallery-image-four.jpg
categories:
- Objects
- Places
- title: five
thumb: img/gallery-image-five.jpg
big: img/gallery-image-five.jpg
categories:
- Objects
- title: eight
thumb: img/gallery-image-eight.jpg
big: img/gallery-image-eight.jpg
categories:
- Places
- title: seven
thumb: img/gallery-image-seven.jpg
big: img/gallery-image-seven.jpg
categories:
- Places
- title: six
thumb: img/gallery-image-six.jpg
big: img/gallery-image-six.jpg
categories:
- Objects
- People
- title: bla
thumb: img/gallery-image-six.jpg
big: img/gallery-image-six.jpg
categories:
- Objects
- People
---
<div class="portfolioFilter">

<a href="#" data-filter="*" class="current">Alle</a>
{% for cat in page.categories %}
<a href="#" data-filter=".{{ cat | slugify }}">{{cat}}</a>
{% endfor %}

</div><br>
<div class="grid">
<div class="grid-sizer"></div>
{% for item in page.images %}
<div class="grid-item{% for cat in item.categories %} {{cat | slugify}}{% endfor %}">
<a class="example-image-link" href="{{item.big}}" data-lightbox="example-set" ><img src="{{item.thumb}}"/></a>
</div>
{% endfor %}
</div>


And here is the error I'm getting:

Error reading file /Users/maxborm/Desktop/lukawebsite/gallery.html: (<unknown>): did not find expected key while parsing a block mapping at line 2 column 1


Thanks in advance.

Answer

Indentation is very important in Liquid, and you have to make sure you have the right amount of spaces when declaring collections.

In your case, you have an extra space before - title: bla which is causing the error.

i.e. you have:

 - title: bla

when you should have:

- title: bla