fabianmichael / kirby-meta

All-in-one solution to all of your SEO/OpenGraph/JSON-LD needs. 👀
MIT License
65 stars 8 forks source link

Hide parent page in sitemap but display children #56

Closed the-leonat closed 8 months ago

the-leonat commented 1 year ago

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
fabianmichael commented 1 year ago

@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 commented 8 months ago

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