Reference

$pages->count()

Counts all elements

$pages->count(): int

Return type

int

Example

Counting first level pages

The site has <?= $pages->count() ?> main pages

Counting subpages

This page has <?= $page->children()->count() ?> subpages

Counting all pages

The site has <?= $site->index()->count() ?> pages in total

Source code

kirby/src/Toolkit/Iterator.php#L105