{% capture collection_name %}{{ include.collection }}{% endcapture %} {% for post in site.[collection_name] %} {% if post.url == page.url %} {% assign post_index0 = forloop.index0 %} {% assign post_index1 = forloop.index %} {% endif %} {% endfor %} {% for post in site.[collection_name] %} {% if post_index0 == forloop.index %}{% assign next_post = post %}{% endif %} {% if post_index1 == forloop.index0 %}{% assign prev_post = post %}{% endif %} {% endfor %} {% if prev_post %}{{ prev_post.title }}{% endif %} {% if next_post %}{{ next_post.title }}{% endif %}