What exactly are page collections?

…the documentation says

To tell Grav that a specific page should be a listing page and contain child-pages, there are a number of variables that can be used:

And from what I understand, those variables can be put into the header of every page into the yaml part. But what does this cause to happen? I don’t understand what I can do with it. Can someone maybe provide a few use cases?

They cause a collection of pages to be collected and made available for a Twig template.

A prime example of this is the blog listing page. You want to display a list of blog posts on a page. So rather than hardcode that list in your Twig for displaying the blog list, you define it in the frontmatter of your page.

This allows you to reuse the blog list page if you need to.

So the page where I define the page collection in the frontmatter is not a blog post itself? Does that mean I have a few blog posts and I create another page which does not contain anything than yaml and the page collection definition?

No, it’s not the blog page itself, it’s the page that display the list of blog posts, the blog list page.

Best to illustrate with an example.

and this is an example blog post:


This page defines this page (as /blog is the the home alias):


Thanks! Now I understand… it really is a handy feature!