Skip to content

Instantly share code, notes, and snippets.

@vassilis
Created August 21, 2012 19:18
Show Gist options
  • Save vassilis/3418476 to your computer and use it in GitHub Desktop.
Save vassilis/3418476 to your computer and use it in GitHub Desktop.
Octopress Pagination
{% if paginator.total_pages > 1 %}
<div class="pagination">
{% if paginator.previous_page %}
<a class="prev" href="{{paginator.previous_page}}">&larr; Prev</a>
{% endif %}
{% for page in (1..paginator.total_pages) %}
{% capture url %}/{{site.pagination_dir}}/page/{{page}}{% endcapture %}
{% if page == 1 %}
{% assign url = "/" %}
{% endif %}
{% if page != paginator.page %}
<a href="{{url}}">{{page}}</a>
{% else %}
<span>{{page}}</span>
{% endif %}
{% endfor %}
{% if paginator.next_page %}
<a class="next" href="{{paginator.next_page}}">Next &rarr;</a>
{% endif %}
</div>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment