Recently I was thinking of adding pagination to my site, and it turned out to be a nighmare. I had to google so many things and waste so much time. After spending considerable amount of time researching, I got it working finally.
The pagination in Jekyll is difficult and it is incomprehensively documented on Jekyll Docs, which makes it pretty difficult to add pagination to the site. Here I am aiming to sum up numerous tutorials which helped me add pagination to my site.
Follow along and do exactly what’s stated and you’ll have the pagination.
1. Install required gems
You need to install the plugin "jekyll-pagination"
.
Edit “config.yml” & “gemfile” file
Add the follwing lines in ‘config.yml’
It should look something like this
Add the following line to “gemfile” located in the root directory.
It should look something like this.
- Open a terminal, navigate to your directory and run the command.
Now you are done with half of the work.
2. Making a page where you list your blogs.
- Make a folder called “blog” in project’s root directory.
- Inside the folder make a file called “index.html”.
3. Put the below code to generate list of posts with pagination.
Now you have your paginated post.
- Not successfull?
- Make sure there’s no typo in any of the entries.
- Make sure you executed every command.
- Comment your issue.