首页 > 解决方案 > 使用 Jekyll 时出现液态语法错误 - 意外字符

问题描述

我正在使用带有大量扩展的 Jekyll。构建工作正常,但是当我调用 Jekyll serve 时,我收到以下警告:

Liquid Warning: Liquid syntax error (line 13): Unexpected character   in "{{forloop.index | minus:1 | modulo:4 }}" in .html
Liquid Warning: Liquid syntax error (line 13): Unexpected character   in "{{forloop.index | minus:1 | modulo:4 }}" in .html

这是上述文件的代码,

<section class="pt-6 pt-md-8 pb-8 mb-md-8">
  <div class="container">
  <!-- Example single danger button -->

  <center><h2>Please choose a category to view</h2></center>
  <hr>  
  {% assign color = "#DA5988,#FF5A5F,#0082C9,#6772E5" %}

  <div class="row">
    {% for category in site.categories %}
    {% assign idx = forloop.index | minus:1 | modulo:4 %}
    {% assign curr_color = color | split:',' | slice:idx %}
        <div class="col-4 mt-5">
                <!-- Card -->
                <div class="card card-border shadow-light-lg lift lift-lg" style="border-top-color: {{ curr_color }};">
                  <div class="card-body text-center">
                    <!-- Text -->
                    <h3 class="text-gray-700 mb-5" style="color:{{ curr_color }}">
                        {{ category | first | split:"-" | join:" " | upcase }}
                    </h3>
                    <!-- Link -->
                    <a href="/articles/{{ category | first }}" style="color: {{ curr_color }};">Show More</a>
                  </div>
                </div>

        </div>
      {% endfor %}
  </div>

  </div> <!-- / .container -->
</section>

您可以在第 13 行看到只有一个空格,我怎样才能摆脱这些警告?

标签: rubyjekyllliquidjekyll-extensionsjekyll-paginator

解决方案


也许考虑检查类别名称本身是否有空格,看看这是否是产生错误的原因。


推荐阅读