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.

[Bug] Sitemap plugin generating URLs with trailing slashes

See original GitHub issue

Environment


  System:
    OS: Linux 4.4 Ubuntu 18.04.1 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 20.40 GB / 31.82 GB
    Container: Yes
    Shell: 4.4.19 - /bin/bash
  Binaries:
    Node: 12.18.0 - /usr/local/bin/node
    npm: 6.14.11 - /usr/local/bin/npm
  npmPackages:
    react: ^16.14.0 => 16.14.0
    react-dom: ^16.14.0 => 16.14.0
    react-ga: ^3.3.0 => 3.3.0
    react-google-recaptcha: ^2.1.0 => 2.1.0
    react-hot-loader: ^4.13.0 => 4.13.0
    react-static: ^7.5.1 => 7.5.3
    react-static-plugin-reach-router: ^7.5.1 => 7.5.3
    react-static-plugin-sitemap: ^7.5.1 => 7.5.3
    react-static-plugin-source-filesystem: ^7.5.1 => 7.5.3
    react-static-plugin-svg: 0.0.1 => 0.0.1
  npmGlobalPackages:
    react-static: 7.5.3

Steps to Reproduce the problem

Base your steps off of any freshly installed react-static template!

  1. npm run build
  2. cat dist/sitemap.xml

Expected Behavior

The sitemap URLs should not have trailing slashes. Google Search Console complains about them.

The sitemap URLs (with slashes) generated for my site do work, but the 404 page flashes before the page content appears.

The example output in the documentation for the sitemap plugin does not have trailing slashes in the URLs.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
philip-healycommented, Jun 2, 2021

Thanks @SleeplessByte and @deiga. I have tracked down the source of the 404 flash by the way - it is because the site is hosted on S3. The behavior around trailing slashes differs from what you would expect. Closing this issue now.

1reaction
philip-healycommented, Jun 1, 2021

@deiga further investigation of the Google Search Console reveals that it’s the same issue - it is flagging a problem because it sees the 404 page first. It’s probably something to do with my router configuration.

Having said that, a config option for toggling slashes at the end of URLs would be welcome, as I consider the ones without slashes to be the canonical ones. Also, as you point out, there is a mismatch between the documented behavior and what is seen in practice.

Should I close this issue and recreate it as a feature request for the config option?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add trailing slash to auto generated sitemap.xml #4134 - GitHub
This results in google indexing the page with a "redirect error". A temporary fix for user created content pages is to add a...
Read more >
Sitemap links do not have trailing / | WordPress.org
The links in the sitemap contain no trailing slash, which WordPress redirects to the URL with the trailing slash. Yes, if you have...
Read more >
sitemap URL without trailing slash 404 error - Stack Overflow
I have wordpress website that I installed google XML Plugin. all urls with and without trailing slash works properly. but for sitemap.xml ...
Read more >
Extra / at the end of some URLs - Sitemap Generator Forum
Hello, you should make sure that there are no links to URLs with trailing slashes on the website and generator will not pick...
Read more >
Redirects module only works on URLs with trailing slashes
As an editor, I want to be create a redirect from "/source-path/" to "/source-path" (remove the trailing slash). This leads to an infinite...
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