简体   繁体   中英

Number inserted by Jekyll into built page

I'm using Github Pages to create a website for school. The website is not technically a blog, so I've been using Jekyll in a fairly unorthodox manner.

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. 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 . Why is this?

{% decrement baseYear %} is decrementing and ouptuting. You can use minus filter instead.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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