2
votes

First off, I am using Jekyll 3.5.1

I have enabled Pagination in my Jekyll config and have added the following to my _config.yml file:

 #pagination
 paginate: 5
 paginate_path: "blog/page:num"

In my root directory, I have created a folder called 'blog' with inside of it an 'index.html' file. Yet, when I try to serve the file I get the warning that pagination can not find an index.html file.

I have also tried to just use the index.html file under root, but that was unsuccesfull as well.

Here you can see the github repo in case that would be of any help.

I have tried to play with the paginate_path as well as with the index.html file. Any help would be appreciated!

The concrete error message is:

Pagination: Pagination is enabled, but I couldn't find an index.html page to use as the pagination template. Skipping pagination.

Any help would be greatly appreciated.

2

2 Answers

0
votes

index.hmtl must not be empty. The pagination template file (as referred by paginatin_path should contain the code to generate each page with the list of posts, as docs suggests, create blog/index.html:

---
layout: default
title: My Blog
---

<!-- 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>
0
votes

One cause of this error message: The Brackets Editor 'Beautifier' command doesn't recognize YAML code when it executes, so it sees the top YAML of your index.html file:

---
layout: default
title: Jekyll Title
---

... and transforms the 4 lines into one continuous line:

--- layout: default  title: Jekyll Themes ---

Jekyll responds with the error message:

Pagination: Pagination is enabled, but I couldn't find an index.html page to use as the pagination template. Skipping pagination."