【问题标题】:cant find the error in jekyll... "did not find expected key while parsing a block mapping"在 jekyll 中找不到错误...“在解析块映射时找不到预期的密钥”
【发布时间】:2016-11-11 23:10:00
【问题描述】:

我是 jekyll 和 Liquid 的新手。前段时间我有这个运行,但不知何故把它搞砸了,没有备份。当发现某些东西时,错误只会转移到其他地方......请看一看。

这是我的代码:

---
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>

这是我得到的错误:

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 

提前致谢。

【问题讨论】:

    标签: html yaml jekyll liquid


    【解决方案1】:

    缩进在 Liquid 中非常重要,你必须确保在声明集合时有适量的空格。

    在您的情况下,- title: bla 之前有一个额外的空格导致错误。

    即你有:

     - title: bla
    

    什么时候应该有:

    - title: bla
    

    【讨论】:

      猜你喜欢
      • 2016-01-09
      • 2022-01-12
      • 2021-01-27
      • 2023-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-17
      相关资源
      最近更新 更多