This guide describes the configuration options available in jekyll-collection-pages and how they interact. Use it as the single reference while wiring the plugin into your site.
Add a collection_pages entry to _config.yml. Each entry targets one collection and one front-matter field:
collection_pages:
- collection: docs
field: category
path: docs/category
layout: category_layout.html
paginate: 6
You can declare multiple collections or multiple fields for the same collection by adding more entries to the array:
collections:
docs:
output: true
articles:
output: true
collection_pages:
- collection: docs
field: category
path: docs/category
layout: category_layout.html
paginate: 6
- collection: articles
field: tags
path: articles/tags
layout: tags_layout.html
paginate: 10
If you only need a single entry, collection_pages can also be a hash (the plugin normalises it internally). The array form keeps things consistent once you add more targets.
Each path above is treated as a template—directory and can take :field and :num as placeholders. It is recommended to set only set the directory since values automatically expand to <path>/:field/page:num/index.html. The first page, and when pagination is off the generator will create pages in <path>/:field/index.html.
collectionStringcollections configuration.fieldString"category") and array values (e.g. "tags").Make sure every document you expect to index sets this field. When the field holds an array, the plugin creates one page per value.
pathString:field and a :num placeholder which are appended to the path if they are ommitted :field/page:num/index.html (recommended).
:field: This placeholder is for the value of the field for the page.:num: This placeholder is for the page number of the pagination.Rules enforced by the generator:
:num is present it must appear after :field, and the two placeholders cannot live in the same segment..html/.htm must include the required placeholders explicitly.path blank defaults to <collection>/:field/index.html (or <collection>/:field/page:num/index.html when paginated).layoutStringcollection_layout.html)_layouts/ to render the generated page.The plugin copies page.posts, page.tag, and optional page.paginator into the layout context.
paginateIntegerpage.paginator exposes page, total_pages, previous_page_path, next_page_path, etc.) and the generated paths already include the tag directory (e.g. docs/category/getting-started/, docs/category/getting-started/page2.html), so piping them through relative_url yields working links.Set paginate to nil, omit the key, or use a non-positive number to render a single page per label. Non-numeric values raise an error during the build, so typos like "ten" fail fast.
At build time the plugin exports site.data.collection_pages[collection_name][field], which contains:
template → the sanitized template used to create each index. Directory values inherit <path>/:field/index.html and add /page:num/ only when pagination is enabled (e.g. /docs/category/:field/index.html or /docs/category/:field/page:num/index.html).permalink → the sanitized template for the index with placeholders intact (no :num, since it always points to page one, e.g. /docs/category/:field/)pages → documents grouped by label ({ label => [documents...] })labels: metadata describing the generated index pagesUse pages to feed existing includes, and labels[label].index.url when you need the generated index URL.
See the Generated data reference for usage patterns and Liquid snippets.
output: true, otherwise links from index pages may 404.field exists in every document; documents missing the field are skipped.bundle exec jekyll build --trace with JEKYLL_LOG_LEVEL=debug to see the plugin’s log output (e.g. total pages generated).site.data.collection_pages in a rendered page ({{ site.data.collection_pages | jsonify }}) when debugging Liquid loops.Ready to dive deeper? Explore the examples for real-world configurations and the layout recipes to customise the rendered pages.