{# Prev/next within the current section, ordered by weight. The first page links back to the section index rather than dead-ending. #} {% for sec in site.sections %}{% if sec.name == page.section %} {% set ordered = sec.pages | rejectattr("is_index") | sort(attribute="weight") %} {% for p in ordered %}{% if p.url == page.url %} {% endif %}{% endfor %} {% endif %}{% endfor %}