简体   繁体   English

Jekyll在构建页面中插入的数字

[英]Number inserted by Jekyll into built page

I'm using Github Pages to create a website for school. 我正在使用Github Pages创建一个学校网站。 The website is not technically a blog, so I've been using Jekyll in a fairly unorthodox manner. 从技术上讲,该网站不是博客,因此,我一直在以非正统的方式使用Jekyll。

Some pages are meant to get all the HTML pages that contain YAML front matter, and only display cards that match the calculated year for that specific page. 某些页面用于获取所有包含YAML前景色的HTML页面,并且仅显示与该特定页面的计算年份匹配的显示卡。 The code for the page is as follows: 该页面的代码如下:

---
layout: default
---

<h1>{{ page.title }}</h1>
<div id="{{ page.domain }}-students" class="card-set student-set">
  {% assign sortedPosts = site.html_pages | sort: 'title' %}
  {% assign monthDifference = site.time | date:"%m" | minus:8 %}
  {% if monthDifference < 0 %}
    {% assign baseYear =  site.time | date:"%Y" | minus:2 %}
  {% else %}
    {% assign baseYear =  site.time | date:"%Y" | minus:1 %}
  {% endif %}
  {% if page.class contains "filmtwo" %}
    {% decrement baseYear %}
  {% elsif page.class contains "filmthree" %}
    {% decrement baseYear %}
    {% decrement baseYear %}
  {% elsif page.class contains "filmfour" %}
    {% decrement baseYear %}
    {% decrement baseYear %}
    {% decrement baseYear %}
  {% endif %}
  {% for student in sortedPosts %}
    {% if student.layout contains "student" %}
      <a href="{{ student.domain }}" id="{{ student.domain }}-card" class="student-card card" style='background-image: url("/images/students/{{ student.domain }}.jpg")'>
        <div id="{{ student.domain }}-caption" class="card-caption" style="background-color: {{ student.theme }}">
          <h2>{{ student.name }}</h2>
        </div>
      </a>
    {% endif %}
  {% endfor %}
</div>

When I build the site and serve it, each page that uses this layout has a number in its content—specifically in the div with ID {{ page-domain }}-students . 当我构建站点并为其提供服务时,使用此布局的每个页面的内容都有一个数字,尤其是在ID为{{ page-domain }}-students的div中。 Why is this? 为什么是这样?

{% decrement baseYear %} is decrementing and ouptuting. {% decrement baseYear %}正在递减。 You can use minus filter instead. 您可以改用减号过滤器。

{% assign baseYear = baseYear | minus: 1 %}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM