I don’t fully understand how to setup subpages with blueprints and can’t find a deep explanation on how to organize pages and subpages in documentation.
I’ve checked:
Documentation on pages: Could not find any reference to subpages other than the document: Subpage-builder
The events example in Events | Kirby CMS. Trying to replicate this, I get the error: " The section “events” could not be loaded: The parent for the query “site.find(“events”)” cannot be found in the section “events” in /panel where the section should be rendered. (I’ve already created a page named events that uses the events template).
My doubt:
In order to have an “events” page which holds a collection of pages of type “event” I understand I need to define two page blueprints:
events.yml
event.yml
How one tells kirby pages using the event.yml are subpages of the event page?
Does events.yml needs to define a section linked to the event.yml template?
Yes, if you want to see the single events on that page, you need to have that section there.
To actually create the events page (or first level parent), you would create a section in site.yml that allows you to create this parent. See site.yml example in the Starterkit, where you have three sections:
one for notes children
one for photography children
one for all other pages (with the create: defaultprop set to only allow creation of new pages with templatedefault`, but that can be changed.
For the first two, the parent pages (notes, photography) need to already exist in the file system.
So, whenever you want to create pages anywhere, you need a pages section that allows you to create pages with a given template.
Thanks for your explanation, now I understand it better.
Yes, I read the “Creating pages” but I could not find anything related to the pages relationships.
In the end, the issue while trying to replicate the events example was that the page I created did not have the slug as “events”, but had a different one, so the site.find("events") failed.
Maybe extending the events example with clear instructions on having to create an Events page would help in that document.
I added a note that the page needs to exist in the example to make it clearer.
But it is not always necessary to explicitly set a parent, as the parent defaults to the current page. This is particularly relevant if you don’t know what the parent page is called beforehand, because it is created via the Panel.