[gatsby-plugin-sitemap] - why remove trailing slash?
See original GitHub issueSummary
The plugin gatsby-plugin-sitemap
removes trailing slashes from paths. For example:
https://www.example.com/test/
becomes https://www.example.com/test
in the generated sitemap.xml
Relevant information
It seems that by design Gatsby redirects to path’s with trailing slashes server-side, for example
$ curl -I http://localhost:9000/test
HTTP/1.1 301 Moved Permanently
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Content-Type: text/html; charset=UTF-8
Content-Length: 177
Content-Security-Policy: default-src 'none'
X-Content-Type-Options: nosniff
Location: /test/
Vary: Accept-Encoding
Date: Mon, 14 Oct 2019 14:35:20 GMT
Connection: keep-alive
Where /test
has a 301 redirect to /test/
.
The result is that Search Engines (e.g. Google) that read the sitemap flag the pages as Duplicate, submitted URL not selected as canonical
. If Gatsby (express) intends paths to end in a trailing slash, then this should be the same in the sitemap.xml
. However this function removes the trailing slash in the sitemap.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top Results From Across the Web
gatsby-plugin-remove-trailing-slashes
This plugin is intended to remove trailing slashes from paths generated by Gatsby itself. This however does not prevent the resolution of pages...
Read more >gatsby-plugin-sitemap Putting trailing slash to homepage only
1 Answer 1 · always: Always add trailing slashes to each URL, e.g. /x to /x/. · never: Remove all trailing slashes on...
Read more >URL trailing slash — Gatsby - DEV Community
Trailing slash is a forward slash / at the end of a URL. People have a difference of opinion whether it's good or...
Read more >gatsby-plugin-remove-trailing-slashes - npm
Removes trailing slashes from your project's paths. ... Start using gatsby-plugin-remove-trailing-slashes in your project by running `npm i ...
Read more >Gatsby: to slash or not to slash? - Pixel Point
Here comes the reason you should use trailing slashes on Gatsby: the path string passed to createPage() becomes a directory, and the resulting ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi I have still the same problem. No trailing slash in the sitemap and no slash at canonical urls.
Would like to keep this open to understand why there is a difference in the resulting sitemap output,