gatsby icon indicating copy to clipboard operation
gatsby copied to clipboard

feat(gatsby-plugin-sitemap): allow path prefix to be ignored for sitemap public path

Open gigaSproule opened this issue 3 years ago • 9 comments
trafficstars

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.

gigaSproule avatar Apr 14 '22 16:04 gigaSproule

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.

gigaSproule avatar Apr 14 '22 21:04 gigaSproule

Any updates on this fix? Or workarounds?

kevinschuit avatar Jul 26 '22 05:07 kevinschuit

I've not had any feedback, but it's been working for all of our sites since April without any issues.

gigaSproule avatar Jul 26 '22 08:07 gigaSproule

thank you for replying, after some changes and upgrades all works fine on our end now as well!

kevinschuit avatar Jul 26 '22 08:07 kevinschuit

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 avatar Jul 26 '22 10:07 pieh

@pieh I've updated the MR. Hopefully that solves your use case.

gigaSproule avatar Jul 26 '22 10:07 gigaSproule

I have the same problem.

shaabanihamed avatar Aug 03 '22 22:08 shaabanihamed

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 avatar Aug 04 '22 22:08 orlandovallejos

@orlandovallejos Sorry, I don't understand what you mean. All the configuration is set in the gatsby-config.js

gigaSproule avatar Aug 22 '22 20:08 gigaSproule

@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.

gigaSproule avatar Aug 04 '23 16:08 gigaSproule