2
votes

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?

1

1 Answers

3
votes

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

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