How to use Jekyll-paginate without index.html?
The documentation for Jekyll pagination says:
Pagination only works within HTML files
Pagination does not work from within Markdown or Textile files from your Jekyll site. Pagination works when called from within the HTML file, named
index.html
, which optionally may reside in and produce pagination from within a subdirectory, via thepaginate_path
configuration value.
So if you want your blog to be on URL /articles/
and /articles/N/
, specify this in your configuration:
paginate_path: "/articles/:num/"
And place an index.html
file inside articles
directory, which lists the posts for the current page:
<!-- This loops through the paginated posts -->
{% for post in paginator.posts %}
<h1><a href="{{ post.url }}">{{ post.title }}</a></h1>
<p class="author">
<span class="date">{{ post.date }}</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>
(See the documentation for more snippets and configuration details.)
EDIT: I think your problem was your paginate_path
setting. You set it to '/page-:num/'
, therefore Jekyll Paginate looked for index.html
in your site root.