Skip to content

Instantly share code, notes, and snippets.

@skinnylatte
Last active October 17, 2016 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skinnylatte/d80e81caeb541229eca201d9d5b2820e to your computer and use it in GitHub Desktop.
Save skinnylatte/d80e81caeb541229eca201d9d5b2820e to your computer and use it in GitHub Desktop.
Jekyll index file template with pagination and nice dates
---
layout: default
---
<!-- This loops through the paginated posts -->
{% for post in paginator.posts %}
<h1><a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a></h1>
<p class="author">
<span class="date">Written on {{ post.date | date: "%B %e, %Y" }}</span>
</p>
<div class="content">
{{ post.content }}
</div>
{% endfor %}
<!-- Pagination links -->
<div class="pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path }}" class="previous">Previous</a>
{% else %}
<span class="previous">Previous</span>
{% endif %}
<span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
{% if paginator.next_page %}
<a href="{{ paginator.next_page_path }}" class="next">Next</a>
{% else %}
<span class="next ">Next</span>
{% endif %}
</div>
@skinnylatte
Copy link
Author

skinnylatte commented Oct 17, 2016

Added {{ site.baseurl }} to make permalinks work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment