-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Recommended method can produce invalid sitemap #11869
Comments
@ShMcK wouldn't it make more sense to remove the trailing slash? We could/should guard against this though with our schema validation of gatsby-config.js, though. We should fix things early (or warn/error/etc.) rather than baking in fixes to all plugins that expect a normalized format. Something like this would be a nice addition: https://runkit.com/dschau/5c6ae2aff8150400120f142c |
I had followed a recommended pattern from the docs which produced this issue. const siteAddress = new URL('https://www.example.com')
module.exports = {
siteMetadata: {
siteUrl: siteAddress.href, // which is "https://www.example.com/"
},
plugins: [
`gatsby-plugin-sitemap`,
]
} I suppose possible solutions are among these:
|
@ShMcK that's not really an officially maintained document - but feel free to PR with any changes as you see fit. Agreed--it's confusing! Also note: they do document this (which would solve the issue) later on:
Easiest course here is to just follow that approach and possibly PR any changes to the Cloudfront doc, as needed. |
In that case, it may be worth replacing this line:
to
Which altogether doesn't seem simpler than just setting a siteAddress variable to a string. |
Of course--that makes sense, yeah. Should probably open up that issue and PR on that repo rather than this one, though.
Agreed - but I think the use case for doing it that way is to programmatically grab the I'm going to close this out - but we'd love a PR beefing up our validation here and possibly warning when a trailing slash is detected in areas like Thanks for opening this issue! |
Opening an issue for the underlying feature request/change here too! Thank you! |
Description
The Gatsby SiteMap plugin should remove any trailing slashes from the siteUrl.
This example will produce an invalid sitemap.
Notice the double slashes following the hostname.
https://www.example.com//somePath
.Solution
The sitemap plugin just needs to remove any trailing slashes from the siteUrl before processing.
The text was updated successfully, but these errors were encountered: