Pagination in GenGen
GenGen provides a powerful pagination system that allows you to split your content across multiple pages, similar to Jekyll's paginate-v2 plugin. This guide covers everything you need to know about setting up and using pagination in your GenGen site.
Overview
The pagination system automatically creates multiple pages from your posts or pages, with each page containing a specified number of items. For example, if you have 27 posts and set items_per_page: 5, GenGen will create 6 pages:
- Page 1:
/(your index.html) - Posts 1-5 - Page 2:
/page/2/- Posts 6-10 - Page 3:
/page/3/- Posts 11-15 - Page 4:
/page/4/- Posts 16-20 - Page 5:
/page/5/- Posts 21-25 - Page 6:
/page/6/- Posts 26-27
Configuration
Basic Configuration
Add pagination configuration to your config.yaml:
pagination:
enabled: true
items_per_page: 5
collection: posts
permalink: '/page/:num/'
indexpage: index
Configuration Options
enabled: Boolean - Enable or disable pagination (default:false)items_per_page: Integer - Number of items per page (default:5)collection: String - Collection to paginate:postsorpages(default:posts)permalink: String - URL pattern for pagination pages (default:/page/:num/)indexpage: String - Name of the index template without extension (default:index)
Advanced Configuration
pagination:
enabled: true
items_per_page: 10
collection: posts
permalink: '/blog/page/:num/'
indexpage: blog-index
Required Files
Index Template (Required)
โ ๏ธ Critical Requirement: Pagination requires an index.html file in your site root. Without this file, pagination will fail with a clear error message.
Create index.html with pagination template code:
---
layout: default
title: "My Blog"
---
Latest Posts
No posts found.
Template Variables
Core Pagination Variables
All pagination data is accessed through page.paginate.*:
page.paginate.items: Array of items for the current pagepage.paginate.current_page: Current page number (1, 2, 3, etc.)page.paginate.total_pages: Total number of pagespage.paginate.items_per_page: Number of items per pagepage.paginate.total_items: Total number of items being paginatedpage.paginate.has_previous: Boolean - true if there's a previous pagepage.paginate.has_next: Boolean - true if there's a next pagepage.paginate.page_trail: Array of page numbers for navigation (e.g., [1, 2, 3, 4, 5])
Navigation Variables
Page of
( of posts)
Template Examples
Simple Post Listing