question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[gatsby-plugin-sitemap] - why remove trailing slash?

See original GitHub issue

Summary

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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
mniedermcommented, May 6, 2020

Hi I have still the same problem. No trailing slash in the sitemap and no slash at canonical urls.

2reactions
rudolphfunkcommented, Nov 7, 2019

Would like to keep this open to understand why there is a difference in the resulting sitemap output,

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found