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

This Stackoverflow question was how to create a multipage blog post with pagination on top and at the bottom for a sample page.

Here’s the sample Wordpress blog post page with separate subpages.

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

Two layouts

Jekyll allows you to add layouts if you HTML structure differs between pages. The page needs two layouts as the startpage differs from all other pages in 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 collection. In this case, the collection is required to have 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

Code (first version) (updated index: index to palettes-index later)

Resulting Jekyll example

Here’s the resulting example using some hacky, not styled, and not optimized. But at least, it should be good to transfer the idea:

https://cadamini.github.io/palettes-index/


Post image: Image by new7ducks on Freepik

Send feedback!

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