The $page object is the heart and soul of Kirby. It is used to construct pages and all their dependencies like children, files, content, etc.

How to fetch the $page object

The $page class is available in Kirby's templates/snippets etc. through the $page variable that - unless otherwise defined – always refers to the current page.

However, you can also define a $page object by calling a specific page using the page() helper:

$page = page('somepage');

Or getting it from a collection of pages

$page = $pages->first();


With the $page object defined, you can start using the methods of the class:

Get a field of the page

<?= $page->title() ?>

Get the children of the page

<?php $children = $page->children() ?>

Get all images of the page

<?php $images = $page->images() ?>

Check if the page is active

<?php e($page->isActive(), 'active') ?>

Check if the page has draft children

if ($page->hasDrafts()) {
  echo "This page still has some children that haven't been published yet";