Skip to content

Kirby 4.4.1

$site

The $site object is the root element for any site with pages. It represents the main content folder with its site.txt.

How to access the $site object

The $site variable is automatically available in your templates and snippets.

To access the $site object in extensions, you have to define it first:

// via the kirby object
$site = $kirby->site();

// using the `site()` helper
$site = site();

Examples

Get the site title

echo $site->title();

Get any custom field of the site

echo $site->description();

Get the files stored in the content folder

$siteFiles = $site->files();

Get all the pages of the site

$pageIndex = $site->index();

Get the URL of the site

$url = $site->url();