nuxt-modules / sitemap

Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.
https://nuxtseo.com/sitemap
336 stars 31 forks source link

help: Sitemap file location #368

Open toytonic opened 1 month ago

toytonic commented 1 month ago

๐Ÿ“š What are you trying to do?

This is more of a question but an actual issue right now. Hope you can help me clarify things a bit.

While playing around with the multiple sitemaps feature, I noticed that the path of every sitemap entry is generated with a loc similar to https:example.com/__sitemap__/[my-sitemap-entry].xml.

A coworker pointed out that the location or path of the sitemap should be considered when using multiple sitemaps. Under https://www.sitemaps.org/protocol.html you can read about it. Basically it says:

The location of a Sitemap file determines the set of URLs that can be included in that Sitemap. A Sitemap file located at http://example.com/catalog/sitemap.xml can include any URLs starting with http://example.com/catalog/ but can not include URLs starting with http://example.com/images/.

So my question is: Isn't this contradicting with the default behavior that multiple sitemaps will always be generated with the __sitemap__ path?

๐Ÿ” What have you tried?

No response

โ„น๏ธ Additional context

No response

harlan-zw commented 1 month ago

Hey, great question. I don't know in this instance, it's possible it does not adhere to the spec but it doesn't explicitly say about having alternative paths when using the root sitemap index file.

No search engine has an issue with it to the best of my knowledge.

The routes are setup like this due to how Nitro route matching works, we can't dynamically match routes such as /<sitemap>-sitemap.xml which means we need to use a middleware that has performance overhead and other drawbacks. This is how it was working in v5 for reference.

I'm open to rolling the change back if it's causing any issues though.

toytonic commented 1 month ago

Thanks for your quick reply. I also can't tell if search engines do have any issues with this. Will get back if I can find any further information on this.

toytonic commented 1 month ago

I found a similar quote in the google docs:

The location of a Sitemap file determines the set of URLs that can be included in that Sitemap. A Sitemap file located at http://example.com/catalog/sitemap.xml can include any URLs starting with http://example.com/catalog/ but can not include URLs starting with http://example.com/images/.

So, if you ask me I would rather go with safe than sorry. But I don't know both how to verify how google really treats sitemaps not following this rule and what consequence a rollback on your side would have.

harlan-zw commented 1 month ago

Add the sitemap to google search console and it should tell you if there's an issues

resolutionathens commented 2 weeks ago

Hey Harlan. Can we revisit this? I, too, would like to be able to control where my sitemaps live. I can create a post-build script to move them out of __sitemap__, but I would rather have a flag within the module config.

harlan-zw commented 2 weeks ago

I am considering rolling the initial change back and allowing people to put them wherever they find appropriate, give me a couple of days to decide.