1

I want to exclude certain URLs from the sitemap, depending on the custom field settings in their corresponding entries. I'm using SEO Matic plugin in craft4

1 Answer 1

2

Currently, the only facility for doing this would be to use an SEO Settings field in that field layout, and manually override the setting on a per-entry basis.

I can think of two possible solutions:

  1. I allow the "Include in Sitemap" field to have a text entry option where you can enter Twig to put your custom condition

  2. Trigger an event that a custom PHP module or plugin can listen for, and do the evaluation there in terms of whether the entry should be included in the sitemap or not

But before we go down that road, can you elaborate on what you're trying to accomplish here? Just excluding something from the sitemap alone does not prevent it from getting indexed.

More here: SEO Myths: Top 5 Sitemap Myths Demystified

3
  • Thanks for your overview. We utilize a custom entry type named Author, featuring a dedicated checkbox field designed to signify whether the author is associated with the period post-2021. When the checkbox is activated, it indicates that an author page need not be created and, consequently, should be excluded from the sitemap. Nonetheless, concerning blog posts, I desire the author's name to be visible without a hyperlink when the checkbox is enabled. If the checkbox is disabled, the link should direct to the author's profile, while if enabled, no link to an author page should be established. Nov 20, 2023 at 8:24
  • Yeah so if it is a public URL, whether it's in the sitemap or not, Google will eventually find it and index it, FWIW. Nov 20, 2023 at 16:18
  • we're in a similar situation over here, and AFAIK: If a URL in your sitemap redirects (301) to a page that ultimately results in a 404 error, Google is unlikely to index the final URL because it signals that the content is not available. While discovery is influenced by the sitemap, the final indexing decision is based on the availability and quality of content at the final URL...isn't it? (BTW: we're doing exactly that: public URL >>> 301 on 404.
    – ricricucit
    Feb 22 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.