{% comment %} The liquid at the top will search through all posts in the series {% endcomment %} {% assign count = '0' %} {% assign index = '0' %} {% assign capture_prev = true %} {% assign capture_next = false %} {% for post in site.posts reversed %} {% if post.series == page.series %} {% capture count %}{{ count | plus: '1' }}{% endcapture %} {% assign last_url = post.url %} {% if capture_next %} {% assign next_title = post.title %} {% assign next_url = post.url %} {% assign capture_next = false %} {% endif %} {% if post.url == page.url %} {% capture index %}{{ count }}{% endcapture %} {% assign capture_prev = false %} {% assign capture_next = true %} {% endif %} {% if capture_prev %} {% assign prev_title = post.title %} {% assign prev_url = post.url %} {% endif %} {% if count == '1' %} {% assign first_url = post.url %} {% endif %} {% endif %} {% endfor %} {% assign after = count | minus: index %} {% comment %} At this point, count is the total number of posts, index is this post, and after is the number of posts after index. We've also captured the first, previous, next, and last posts in the series. {% endcomment %} {% if count > '1' %} {% assign series_page = page.series | slugify | append: ".html" %}