Jekyll-paginate-v2: my posts are not shown on the page

906 Views Asked by At

In my Jekyll 4 site I have a /blog/index.html page. In the correspondent layout I just put the code from the jekyll-paginate-v2 github repo (01-typicalblog). I am using jekyll-paginate-v2 3.0.0.

Here's the code of the /blog/index.html page:

<ul class="post-list">
  {% for post in paginator.posts %}
  <li>
    <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>

    <h2>
      <a class="post-link" href="{{ post.url | relative_url }}"
        >{{ post.title | escape }}</a
      >
    </h2>
  </li>
  {% endfor %}
</ul>

{% if paginator.total_pages > 1 %}
<ul class="pager">
  {% if paginator.previous_page %}
  <li class="previous">
    <a
      href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}"
      >&larr; Newer Posts</a
    >
  </li>
  {% endif %} {% if paginator.next_page %}
  <li class="next">
    <a
      href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}"
      >Older Posts &rarr;</a
    >
  </li>
  {% endif %}
</ul>
{% endif %}

And here is in my config.yaml file:

permalink: /:year-:month-:day-:title/

pagination:
  enabled: true
  per_page: 3
  permalink: "/page/:num/"
  title_suffix: " - page :num"
  limit: 0
  sort_field: "date"
  sort_reverse: true

The front matter in the /blog/index.html page has:

pagination:
  enabled: true

I have been trying to change /page/:num/ with /blog/:num/ and /blog/page/:num/ to no avail. (I am still a beginner in the field). I put the plugin both in the Gemfile and the config.yaml file and followed all the steps form the "01-typicalblog" example page (https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples/01-typicalblog). I also deleted several times the Gemfile.lock to avoid any caching problem.

When I serve the site I see this in the terminal:

Pagination: Disabled in site.config.

But as you can see, I did enable it in both the page font matter and the config file. I have been looking for days for possible solutions but I can't find much material on paginate-v2 and hope that someone could help me.

Thanks in advance!

2

There are 2 best solutions below

1
On

in your case you must insert pagination: enabled: true in index.md also

1
On

jekyll-paginate-v2 does not work properly with jekyll 4. I run into similar issues.

https://github.com/sverrirs/jekyll-paginate-v2/issues/165

jekyll-paginate-v2 version 3 seems to have fixed the issues https://rubygems.org/gems/jekyll-paginate-v2/versions/3.0.0