Skip to content

Kirby 3.5.7.1

$site->index()

Creates a flat child index

$site->index(bool $drafts = false): Kirby\Cms\Pages

Parameters

Name Type Default
$drafts bool false

Return type

Kirby\Cms\Pages

Parent class

Kirby\Cms\Site

// goes through any subpage, subsubpage, etc. below $page and returns them by template
$articles = $site->index()->filterBy('template', 'article');

// the index method is also perfect for a site-wide search
$results = $site->index()->search('mysearchword');

Details

$site->index() reads the entire folder structure including all files. Especially on large sites with many files, using $site->index() can result in big performance issues, so use with caution.