With YAML content and the pages field you can easily link information on your site with other sources in Kirby. All examples below are based on the Starterkit.
Add a new field to any of your content files to which you'd like to add related pages:
You are free to name the field that contains the related pages however you like, as long as you take care of using the right variable in the template later.
Add any number of related pages with the YAML syntax. To link pages, store their URI (the URL without your domain) in the content file. Since the URI is unique, Kirby will always be able to find the right page, even if you change its content or its sorting number. You have to be careful, however, if you change the location of a page or its folder name.
Accessing those related posts in your templates could look like this:
If you use the Panel, you have to add the
related field to your blueprint. The pages field offers a great way to select one or more related articles.
We use the
query option to display all sibling pages of the current page in the list. By passing
false to the
siblings() method, we exclude the current page from the list – we don't want the article itself to be a related article. Learn more about our query syntax.