Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering out Elements in Sitemap #1553

Open
dusan-stojnic opened this issue Dec 23, 2024 · 7 comments
Open

Filtering out Elements in Sitemap #1553

dusan-stojnic opened this issue Dec 23, 2024 · 7 comments
Labels

Comments

@dusan-stojnic
Copy link

Hello,

is there a way to filter out Elements based on field values when generating sitemap, but without creating sitemap indexes?

Tried with IncludeSitemapEntryEvent event, but since we have large amount of Elements, SEOmatic still generated empty sitemap indexes for the number of all Elements before filtering out.

@khalwat
Copy link
Collaborator

khalwat commented Dec 23, 2024

Can you tell me what you're trying to accomplish here?

@dusan-stojnic
Copy link
Author

So, let's say, as an example, we have a section named Posts with 20k entries in it and there is a lightswitch field in the field layout.

By default, Seomatic Sitemap will generate 40 index sitemaps (500 entries each).
Now, lets say i wanted to add only entries where lightswitch is true, to the sitemap.

Tried doing that with event i mentioned above, but result was still 40 index sitemaps, although, most of the were empty.

@dusan-stojnic
Copy link
Author

Managed to achieve this by modifying Element Query, through an event, before it gets processed by Seomatic's Sitemap Controller and guarding it by checking Craft::$app->controller instanceof SitemapController.

Would be super sweet to have the event in Sitemap Controller where seoElement query is being made to modify it.

@khalwat
Copy link
Collaborator

khalwat commented Dec 24, 2024

Right so what I mean is on a higher level perspective... what are you trying to do by excluding some of these entries from the sitemap?

Normally, you'd just set the entry to Disabled which would cause it to not appear in the sitemap, and also cause the URL to not respond on the frontend.

You generally don't want to bother excluding an entry from a sitemap unless the URL isn't publically available as well.

ref: https://nystudio107.com/blog/seo-myths-top-5-sitemap-myths-demystified#seo-myth-3-if-a-url-is-not-in-your-sitemap-it-isnt-indexed

@dusan-stojnic
Copy link
Author

So, i guess i will go into more specific details on what we need.

We have a massive category group. Some Categories there are supposed to have URLs, some lead to search page with predefined query and some have neither. We only want to add to the sitemap the ones that have URLs and are actual pages.

@khalwat
Copy link
Collaborator

khalwat commented Dec 28, 2024

Hrm. Interesting IA challenge. So you want an event thrown that allows you to modify the Sitemap query before it is executed, essentially?

@dusan-stojnic
Copy link
Author

Exactly, that would be amazing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants