Skip to content

Kirby 4.2.0

$site->index()

Creates a flat child index

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

Parameters

Name Type Default Description
$drafts bool false If set to true, draft children are included

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.