Closed tibbis closed 4 months ago
You can do this via PHP:
The event that is triggered when an entry is about to be included in a sitemap.
use nystudio107\seomatic\events\IncludeSitemapEntryEvent;
use nystudio107\seomatic\helpers\Sitemap;
use yii\base\Event;
Event::on(
Sitemap::class,
Sitemap::EVENT_INCLUDE_SITEMAP_ENTRY,
function(IncludeSitemapEntryEvent $event) {
$event->include = false;
}
);
An easier way would also to include an SEO Settings field in the given Section, and instead of using a custom field to determine whether it is indexed or not, allow the content author to override the Robots field via that SEO Settings field.
That will eliminate the need for an extra custom field, automatically set the entry to not be indexed by Google et al via the <meta name="robots">
tag, and also exclude it from the sitemap.
oh I didn't see that it added a new field type! thanks! One feature idea would then be to have the robots field in the section type to "Select from field" 😊
Question
If I set a specific channel entry to noindex,nofollow in the twig code manually depending on a custom field (entry.enableIndexing) I don't want the entry page to be shown in the sitemap. The entry is part of a section channel that has sitemap enabled by default in SEOmate plugin.
How can I do this based on a field entry.enableIndexing?
I can't set robots to none in the plugin setting for that section as it will override all entries to none.
For now I only see a solution to have a separate section type for these pages instead and set robots to none in the plugin settings of that section type, but that is a bit messy.