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

help: Sitemap file location #368

Open
toytonic opened this issue Oct 1, 2024 · 7 comments
Open

help: Sitemap file location #368

toytonic opened this issue Oct 1, 2024 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@toytonic
Copy link

toytonic commented Oct 1, 2024

📚 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

@toytonic toytonic added the help wanted Extra attention is needed label Oct 1, 2024
@harlan-zw
Copy link
Collaborator

harlan-zw commented Oct 1, 2024

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
Copy link
Author

toytonic commented Oct 1, 2024

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
Copy link
Author

toytonic commented Oct 2, 2024

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
Copy link
Collaborator

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

@resolutionathens
Copy link

resolutionathens commented Nov 1, 2024

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
Copy link
Collaborator

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.

@harlan-zw
Copy link
Collaborator

I'll avoid rolling back for now due to potential breaking changes for end users but you can easily change the multi-sitemap path using sitemapsPathPrefix and prefix your sitemaps however you like.

export default defineNuxtConfig({
   sitemap: {
      sitemapsPathPrefix: '/',
      sitemaps: {
         ['sitemap-foo']: {}
      }
   }
})

I've added this to the docs as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants