Pagination navigating to ./index.md instead of ./blog/index.html

Hi there,

The issue: You can click on ‘Older’ to get to the second page of older blog posts (please see button in the bottom right of bgigurtsis dot com/blog/). However, clicking on ‘Newer’ once on that second page takes you to the homepage, as opposed to the page you were just on listing the newer blog posts.

I’ve made this GIF to illustrate the issue: https://i.imgur.com/JN9qXoN.gif

My setup I’m using a Jekyll theme hosted on AWS Amplify. Usually for this theme the index page is where all the blog posts are. I changed this so the index page is a ‘welcome’ post with a hyperlink to the blog instead.

To achieve this:

  1. I moved index.html (pagination code) from my root dir into a folder called ‘blog’
  2. Added an index.md (welcome page) in my root directory.
  3. Added this code to my _config.yml: paginate_path: “/blog/page:num”

Here’s the folder structure:

website
├── config.yml
├── index.md (welcome post)
├── blog
------ ├── index.html (paginate code)

├── posts
------ ├── post1.md
------ ├── post2.md
------ ├── post3.md
------ ├── post4.md
------ ├── post5.md

My _config.yml build settings:

# Build settings
markdown:     kramdown
redcarpet:
  extensions: ['smart', 'tables', 'with_toc_data']
permalink: /blog/:title
paginate_path: "/blog/page:num"
paginate:     4
sass:
  style: compressed
plugins:
  - jekyll-paginate
  - jekyll-sitemap

Here is the frontmatter for blog/index.html

---
layout: default
---

The homepage for my blog is here bgigurtsis dot com
The repistory for the blog is here bgigurtsis/blog

Pagination links the button “Older” to my homepage instead of the first page of my blog. It seems like pagination dosen’t know that bgigurtsis dot com/blog is the first page of blog posts but i’m not sure how to fix this. Any ideas? Thanks!

Have you looked at paginate in action on the sites? Maybe that’s how it works.

I have not. If this is the case my question then becomes how do I change it so it goes back to page 1 of my blog.

Or disable the next button.

Typically you’d have

First Prev Next Last

Or some dots in the middle

1 2 3 ... 20 21

Solved!

In my _includes/pagination.html it specifies where to navigate when you click “Newer”. This is set my default to /. I changed this to /blog.

The full change can be seen here: test new pagination · bgigurtsis/blog@72f6210 · GitHub

1 Like

Glad its working

Consider moving that to config.

page_newer: /blog

Use as

{{ site.page_newer }}
1 Like