Skip to content

Kirby 4.4.1

url()

Builds an absolute URL for a given path

url(?string $path = null, array|string|null $options = null): string

Parameters

Name Type Default
$path string|null null
$options array|string|null null

Return type

string

Examples

Generate a link to a page, e.g. search

<a href="<?= url('search') ?>">Search</a>

Generate a link to a page with query string:

<a href="<?= url('search', ['query' => ['q' => 'validators', 'area' => 'reference']]) ?>">Search</a>

Generate a link to a page with params:

<a href="<?= url('blog', ['params' => ['category' => 'travel', 'tag' => 'beach']]) ?>">Search</a>