fabianmichael / kirby-meta

All-in-one solution to all of your SEO/OpenGraph/JSON-LD needs. đź‘€

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Excluding a page from the sitemap also excludes its children

bogdancondorachi opened this issue · comments

Hello @fabianmichael, not sure if this is intended or not.

If you are trying to exclude a template/s or a page/s from sitemap in config it also excludes its children by default.

Now in my use case, I have a page template and that page acts as a redirect to it's first children. And I need to exclude the parent template to solve some google console issues.

To do so I've manually removed the following from isPageIndexible function:

if (! is_null($page->parent())) {
    // test indexability of parent pages as well
    return static::isPageIndexible($page->parent());
}

Hey @bogdancondorachi, for some reason I had the very same problem a few times now and realised, that this is indeed a design flaw of the plugin. You can use the meta.sitemap.urlhook to circumvent this problem for now without altering the plugin’s code:

# site/config/config.php


return [
	'fabianmichael.meta.sitemap.templates.includeUnlisted' => true,
	'hooke' => [
		'meta.sitemap.url' => function (Page $page) {
			// Add your own logic here, return false is a page should
			// not be indexed
		},
	],
],

Thanks, I've managed to exclude my desired template pages from sitemap without affecting their children using that hook.

'meta.sitemap.url' => function ($page) {
    if ($page->intendedTemplate()->name() === 'doc-head') {
        return false;
    }
},

Though it works, the panel status still shows as indexed but I guess it's nothing to be done in this circumstance until it is addressed in the core. Related maybe to #61 ??

Thanks, I've managed to exclude my desired template pages from sitemap without affecting their children using that hook.

'meta.sitemap.url' => function ($page) {
    if ($page->intendedTemplate()->name() === 'doc-head') {
        return false;
    }
},

Though it works, the panel status still shows as indexed but I guess it's nothing to be done in this circumstance until it is addressed in the core. Related maybe to #61 ??

Yep, unfortunately the page method for calculating the robots meta tag currently happens at another place and has to be dealt with separately.