{% if page.categories %} {% assign currentCat = page.categories[0] %} {% assign links = site.docs | sort: 'order' | where: 'category', currentCat %} {% endif %} {% for link in links %} {% if link.title == page.title %} {% unless forloop.first %} {% assign prev = tmpprev %} {% endunless %} {% unless forloop.last %} {% assign next = links[forloop.index] %} {% endunless %} {% endif %} {% assign tmpprev = link %} {% endfor %}