kirby-meta icon indicating copy to clipboard operation
kirby-meta copied to clipboard

Hide parent page in sitemap but display children

Open the-leonat opened this issue 1 year ago • 1 comments

I wonder if it is possible to hide a parent page in the sitemap but to list its children.

Either unlisting the parent page and adding to config:

    "fabianmichael.meta.sitemap.pages.includeUnlisted" => [
        "parent/*"
    ],
    --> parent is included

or listing the parent and hiding by template or page id with does not help.

    "fabianmichael.meta.sitemap.pages.exclude" => [
        "parent"
    ],
    --> parent and children are excluded

the-leonat avatar Oct 14 '23 13:10 the-leonat

@the-leonat This is clearly a design-issue of the plugin. You can use the following workaround by adding a hook to you config file:


use FabianMichael\Meta\PageMeta;
use Kirby\Cms\App;
use Kirby\Cms\Page;

return [
	'hooks' => [
		'meta.sitemap.url' => function (
			App $kirby,
			Page $page,
			PageMeta $meta,
			DOMDocument $doc,
			DOMElement $url) {
				if ($page->is(page('/* find target page here or any other condition */))) {
					return false;
				}
		},
	]
];

fabianmichael avatar Oct 16 '23 12:10 fabianmichael

Version 2.0.0 will not hide child pages any longer, if their parent page is unlisted.

fabianmichael avatar Mar 22 '24 17:03 fabianmichael