1

I have a website made by docusaurus 2.0.0-beta.18. I realize that, in production, when I click on items in the sidebar it first goes to https://example.com/docs/a-page. If I reload the page, the url becomes https://example.com/docs/a-page/. This problem does not exist in localhost.

I think a url should be consistent before and after reloading. And like StackOverflow, a good style is not having / in the end.

I searched issues of Docusaurus and it seems that trailingSlash would be the solution. So I added trailingSlash: false under module.exports in docusaurus.config.js.

Then, I deployed this change to my production server with docker and nignix. Loading most of the pages of the website returned a 404 error, while static contents could be loaded. Reloading nginx or recreating docker containers did not help.

So does anyone know if trailingSlash: false would solve this trailing slash problem? And is the 404 error due to trailingSlash?

SoftTimur
  • 5,630
  • 38
  • 140
  • 292
  • 1
    What hosting provider are you using? The issue could be down to their behavior (https://github.com/slorber/trailing-slash-guide). Or else it could be your nginx configuration. I know that the `trailingSlash` configuration element does work (at least on docusaurus 2.2.0 [ e.g: https://cs-exams.com ]). – nating Feb 22 '23 at 13:54
  • are you sure 404 is not being caused by any other error, check the logs and see if any configuration needs to be updated to handle the trailingSlash: false case since this is a valid change – Bijendra Feb 23 '23 at 10:21

0 Answers0