Paginate not showing page 2


#1

I have tried many different combinations to get this right, but nothing is taking.
Jekyll 3.7.3. I installed paginate using a ruby gem installation so i think everything’s fine on that side of things but happy to do some more checks.

The architecture of the site doesn’t show the blog on the homepage (which are rendered out of the /_posts folder).
I use an index.md file to set my homepage, and a blog.md page to show the blog.

I had tried also putting index.html in the root and setting the frontmatter to be /blog/ which actually worked but this is probably bad to do because of the redundant index. It also didn’t show anything on page2.

So I move index.html into a folder called /blog

frontmatter:
layout: blog
permalink: /blog/
title: Blog

config:
paginate: 2
paginator_path: “blog/page:num”

Now i get nothing really, my blog page shows it trying to run through the paginator loop but it’s dead.

Previous Page: of Next


#2

I don’t use it but when I played with it it had to specifically be on a page that was called index - didn’t work anywhere else. If you do it on your home page / index page can you get it to work?

Have you tried v2?


#3

No I don’t think I tried that version so will give it a shot.

I thought it was ok if the index.html had frontmatter which referenced a layout that has the paginator code on it.


#4

i tried to update to jekyll-paginate-v2 by doing the following:

I ran gem install jekyll-paginate-v2 in the folder of my site
then i went into the Gemfile and changed

group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.6"
  gem "jekyll-paginate"
end

to

group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.6"
  gem "jekyll-paginate-v2"
end

in config I changed

plugins:
  - jekyll-feed
  - jekyll-paginate

to

plugins:
  - jekyll-feed
  - jekyll-paginate-v2

then i got this error:

Pagination: You are running jekyll-paginate backwards compatible pagination logic. Please ignore all earlier warnings displayed related to the old jekyll-paginate gem.
jekyll 3.7.3 | Error: Legacy jekyll-paginate configuration compatibility mode has expired. Please upgrade to jekyll-paginate-v2 configuration.


#5

not sure but I think it wants you to do a full configuration in the config file:


#6

Jekyll’s default pagination plugin is extremely picky.

  1. It only works with index.html files and you can’t use it with a Markdown file.
  2. You can only paginate one set of pages. Which means you can’t paginate your home page and paginate a set of blog posts at /blog.

You were on the right track with using an index.html. To get this working:

  1. You can keep your index.md as that seems to be just a homepage with no paginated content.
  2. Rename blog.md to /blog/index.html and remove permalink: /blog from it’s front matter. As noted in the docs pagination won’t work when setting a permalink.
  3. Use the _config.yml settings you had above, they should work now
    paginate: 2
    paginate_path: "blog/page:num"
    

jekyll-paginate-v2 is good alternative if you need to paginated multiple sets of pages. As @rdyar suggested, you’ll need to use their full configuration. It’s been sometime since I set it up on a site, but I believe they’ve deprecated the old configs that picked up jekyll-paginate settings. That’s likely why it didn’t work for you.

But seeing how you’re only paginating blog posts I think you can get the default plugin to work with the adjustments above.


#7

Ok I rolled back to the basic paginate plugin to try to get this one working first.
I removed permalink: /blog from the blog/index.html page. I made sure to include the paginator_path: “blog/page:num”

restarting the server I get:

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

on localhost:4000/blog I still see

Previous
Page: of
Next

However the sidebar loaded with the posts and categories.

<div class="col-12 col-md-8 col-lg-7">    

  {% for post in paginator.posts %}
<div class="row"> 
<div class="col" style="margin-bottom:30px;">
     <h3 style="margin:0;padding:0;"> <a href="{{ post.url }}">{{ post.title }}</a></h3> <br />

    {% if post.categories contains "video" %}

<div class="embed-responsive embed-responsive-16by9">
  <iframe class="embed-responsive-item" src="https://www.youtube.com/embed/{{page.ytstring}}?rel=0" allowfullscreen></iframe>
</div> 
{{post.content}}

{% else %}

{{post.content }}

{% endif %}

</div> <!-- end column for post -->
  </div> <!-- end row for post -->
  {% 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>


</div> <!-- end column for all posts -->

#8

You have a public repo somewhere I can look at?
I’m pretty sure you have multiple paginator.posts loops out there and it’s getting confused.

It can only be used once, and needs to be in either the layout or the page content you’re using for /blog/index.html. If that logic is in the layout and that’s being used in your index.md at the root of the site that could be causing issues too.

As mentioned earlier the default pagination plugin is extremely picky. If you have one thing out of whack and not how it expects it won’t work.


#9

@mmistakes was able to take a look offline and found that I had written paginator_path: in my config file.

Thanks for the help team, I think I should be sorted for this version and then will be try moving onto v2 of the plugin when i’m ready :grinning: