How can I create a multi-page blog post in Jekyll?

Edit this page on Github

This Stackoverflow question asked how to create a multipage blog post with pagination and shared this sample WordPress page with separate subpages.

Approach

I created a new collection, two layouts, and two include files in Jekyll.

Two layouts

Jekyll allows you to add layouts if your HTML structure differs between pages. The page needs two layouts as the start page differs from all other pages on the site. Each layout contains two for loops to create links to the subpages on top and at the bottom.

The collection

Jekyll offers posts and collections. In this case, the collection is required to have a folder to store pages and to have links to the single pages.

Includes

Jekyll has includes for shared content. The pages share some content in different places, e.g. the page about Wes and the other artists, depending on which link you click.

Code

The Stackoverflow answer shares some code, too. You can find all files in GitHub in this commit. Note that I updated the index page to palettes-index later.

Jekyll result

This [non-styled example page](https://cadamini.github.io/palettes-index/](https://cadamini.github.io/palettes-index/) should transfer the idea well enough.


Post image: Image by new7ducks on Freepik

Send feedback!

<b>Written by:</b> Christian
Written by: Christian Technical writer, nerd, father.