gatsby
gatsby copied to clipboard
feat(gatsby-plugin-sitemap): allow path prefix to be ignored for sitemap public path
Description
When an asset prefix is provided, the sitemap-index.xml file has the extra asset prefix provided. In our case, we do not want our sitemap files to be referenced with the asset prefix, but we still need the asset prefix for other features of our site.
Documentation
I've updated the README.md.
Related Issues
Seems like this was originally attempted with PR #32107 which is related to this issue #34010. The PR #32107 had a suggestion to simply provide an option to ignore the asset prefix, which is ideal for us.
I'm not sure why the tests are failing. When I run just the tests for the sitemap plugin, I get the same test failures for master as I do this branch. As for running the tests for all the others, again I get the same test failures on master as this branch.
Any updates on this fix? Or workarounds?
I've not had any feedback, but it's been working for all of our sites since April without any issues.
thank you for replying, after some changes and upgrades all works fine on our end now as well!
I've looked at what is produced for sitemap and it just looks like when assetPrefix and pathPrefix are used the output is completely borked as it generates something like this http://localhost:9000/localhost:9001/blog/sitemap/sitemap-0.xml for our e2e/path-prefix (where http://localhost:9000 is siteUrl in gatsby-config, assetPrefix: http://localhost:9001,
pathPrefix: /blog,)
This will never be correct, so leaving default as-is will be leaving it in borked state.
Now with the PR after I enabled new option, I'm getting http://localhost:9000/sitemap/sitemap-0.xml which is also not correct (missing blog) - it should be http://localhost:9000/blog/sitemap/sitemap-0.xml ?
@pieh I've updated the MR. Hopefully that solves your use case.
I have the same problem.
I've not had any feedback, but it's been working for all of our sites since April without any issues.
@gigaSproule How did you make the reference to the sitemap in your project package.json? I can't make it work on mine
@orlandovallejos Sorry, I don't understand what you mean. All the configuration is set in the gatsby-config.js
@pieh I think I've addressed your changes. I've tried changing a few things to get the build to pass, but it seems like what is failing has nothing to do with my changes.
The windows_unit_tests are failing for mutex shouldn't wait if keys are different which is marked as flakey in CircleCI and worker can access node created in main process timed out, so maybe a knock on effect of the flakey test?
The e2e_tests_development_runtime_with_react_18 is failing because Your callback function returned a promise that never resolved. in should load only once if the page is revisited via browser back/forward buttons after Gatsby link navigation, which again sounds unrelated to the changes I've made.