Skip to content

Kirby 4.2.0


Search all pages in the site

$site->search(?string $query = null, array|string $params = [ ]): Kirby\Cms\Pages


Name Type Default
$query string|null null
$params array|string [ ]

Return type


Parent class


Parameter options

Option Default Description
minlength 2 Minimum length of search word
fields [] Fields to search in, defaults to all fields
words false Search full words only
score ['id' => 64,'title' => 64] Score per field
stopwords [] Array of words to exclude from search


// search the entire site
$results = $site->search('my awesome search');

// filter the search results
$results = $site->search('my awesome search')->listed()->filterBy('template', 'article');

// add pagination to the search results
$results = $site->search('my awesome search')->paginate(20);

// search in certain fields only
$results = $site->search('my awesome search', 'title|text');

// search for full words only
$results = $site->search('my awesome->search', ['words' => true]);

// feed the search with a get parameter ->
$results = $site->search(get('q'));

More information

Setting up a search page