 <pre><code>{% for category in site.categories %} {% assign catg_name = category.first %} {% if catg_name == page.category %} {% assign catg_posts = category.last %} {% endif %} {% endfor %} {% for post in catg_posts %} {% if post.title == page.title %} {% unless forloop.last %} {% assign next = catg_posts[forloop.index] %} &lt;li class="previous"&gt; &lt;a href="{{ site.baseurl }}{{ next.url }}"&gt;&amp;larr;{{ next.title }}&lt;/a&gt; &lt;/li&gt; {% endunless %} {% unless forloop.first %} &lt;li class="next"&gt; &lt;a href="{{ site.baseurl }}{{ prev.url }}"&gt;{{ prev.title }}&amp;rarr;&lt;/a&gt; &lt;/li&gt; {% endunless %} {% endif %} {% assign prev = post %} {% endfor %} </code></pre> <p>As you have mentioned you can save and use the previous iteration value for the previous post link( in my case I use it as the next post link since I don't want the default newest-first order ). For the next array element you can use <code>forloop.index</code>. This is the 1-based index of the for loop and will give you the next item of a zero-based array.</p>