I did not like the solution from @pixelijn, b/c it has hardcoded values. So I built a little snippet, that allows me to include children in the ignore list (e.g. “[‘error’, ‘mypage/*’]”).
[
'pattern' => 'sitemap.xml',
'action' => function () {
$pages = site()->pages()->index();
$ignores = kirby()->option('sitemap.ignore', ['error']);
// Allow ignore option to include children via 'page/*' syntax
$ignoresExpanded = [];
foreach ($ignores as $ignore) {
if (str_ends_with($ignore, '/*')) {
$ignore = substr($ignore, 0, -2);
foreach ($pages as $page) {
if (str_starts_with($page, $ignore)) {
array_push($ignoresExpanded, $page);
}
};
}
}
$ignore = array_merge($ignores, $ignoresExpanded);
$content = snippet('sitemap', compact('pages', 'ignore'), true);
return new Kirby\Cms\Response($content, 'application/xml');
}
],