Skip Navigation


Sitemaps are enabled by default. You can disable them by setting to false in your config.php.

Pages will only be listed if the Robots rules (and its cascading fields) allow it; except if a custom generator function is provided that might provide different behaviour.

A nice looking stylesheet inspired by the Kirby panel will be added automatically as well.


tobimori.seo.sitemap. Default Accepts Description
active true boolean Enable/disable the entire sitemap module
lang en string|callback Language of the sitemap (human readable strings)
changefreq weekly string|callback Change frequency of an URL
priority fn () => [...] string|callback Priority of an URL
groupByTemplate false boolean Create separate sitemaps for each template type
excludeTemplates ['error'] array Exclude templates from default sitemap generator
generator fn () => [...] callback Generator function for the sitemap

Options allow you to fine tune the behaviour of the plugin. You can set them in your config.php file:

// site/config/config.php

return [
    'tobimori.seo.sitemap' => [
        'groupByTemplate' => false, // Create separate sitemaps for each template type
        'excludeTemplates' => ['error'], // Exclude templates from sitemap
        'changefreq' => 'weekly', // Change frequency, can be a string or a function
        'priority' => fn (Page $p) => number_format(($p->isHomePage()) ? 1 : max(1 - 0.2 * $p->depth(), 0.2), 1), // Priority, can be a string or a function

Customizing the generator function

Sitemaps are generated by a generator function, which you can override in your config.php file, if the above mentioned config options don't fulfill your needs. The default function looks something like this:

The generator function allows you to programmatically generate sitemaps and add URLs to them. When a sitemap route is requested, this generator function will automatically be invoked to add content to the sitemap.

return [
    'tobimori.seo.sitemap.generator' => function (SitemapIndex $sitemap) {
        $pages = site()->index()->filter(fn ($page) => $page->metadata()->robotsIndex()->toBool())->group('intendedTemplate');

        foreach ($pages as $group) {
            $index = $sitemap->create($group->first()->intendedTemplate()->name());

            foreach ($group as $page) {
            $url = $index->createUrl($page->metadata()->canonicalUrl())

(This is a simplified version of the actual function, which you can find in the source code.)

If only a single sitemap is defined, the sitemap index route will directly render that sitemap instead of first generating a sitemap index file.

Note that if you provide a custom sitemap generator function, the standard sitemap configuration options are ignored. However, you can access and utilize those configuration values within your own generator function if desired.

Support Kirby SEO development:
Get a Stay Awesome License

Kirby SEO is available completely free of charge.
If you’re using it to deliver a commercial project, please consider supporting further development & maintenance financially.