使用Jekyll时出现语法错误

问题描述 投票:1回答:1

我正在将Jekyll与一堆扩展名配合使用。构建工作正常,但是当我致电Jekyll服务时,会收到以下警告:

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行上看到,只有一个空格,我如何摆脱这些警告?

ruby jekyll liquid jekyll-extensions jekyll-paginator
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.