Skip to content

Instantly share code, notes, and snippets.

@gfscott
Created August 28, 2025 00:14
Show Gist options
  • Select an option

  • Save gfscott/2d5ac3cb1c212d36627b19cc7803cd93 to your computer and use it in GitHub Desktop.

Select an option

Save gfscott/2d5ac3cb1c212d36627b19cc7803cd93 to your computer and use it in GitHub Desktop.
11ty pagination with Nunjucks
{% if (pagination.pages.length > 1) %}
<nav class="pagination">
<span>Page: </span>
{% for pageEntry in pagination.pages %}
{% if page.url == pagination.hrefs[ loop.index0 ] %}
<span class="pg" aria-current="page">{{ loop.index }}</span>
{% else %}
<a href="{{ pagination.hrefs[ loop.index0 ] }}">{{ loop.index }}</a>
{% endif %}
{% endfor %}
</nav>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment