Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links to other docs pages are broken in github pages due to additional / #5026

Closed
5 tasks done
F43nd1r opened this issue Jun 21, 2021 · 4 comments
Closed
5 tasks done
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: question This issue is a user error/misunderstanding.

Comments

@F43nd1r
Copy link

F43nd1r commented Jun 21, 2021

🐛 Bug Report

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io
  • I have read the console error message carefully (if applicable)

Description

Deep links don't work correctly when deployed to github pages. Example:
this link points to .../create-a-page, but is redirected to .../create-a-page/. Displaying the page works, but clicking a link to another page (here Congratulations), loads .../create-a-page/congratulations instead of the correct .../congratulations

Have you read the Contributing Guidelines on issues?

Yes

Steps to reproduce

Use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.

(Write your steps here:)

  1. Clone Demo
  2. Add a link to a doc page (2) to a docs page (1)
  3. Deploy to Github Pages
  4. Access page (1) via direct link
  5. Click on the added link
  6. Observe Page Not Found

Expected behavior

Links to other pages behave correctly when the url has an additional slash appended.

Actual behavior

Links to other pages don't work when the url has an additional slash appended.

Your environment

Reproducible demo

https://github.com/F43nd1r/docusaurus-link-issue-reproducer

Go to https://f43nd1r.github.io/docusaurus-link-issue-reproducer/, click the link and then click on the congratulations link in the page.

@F43nd1r F43nd1r added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jun 21, 2021
@slorber
Copy link
Collaborator

slorber commented Jun 21, 2021

That's funny because this issue is solved by the brand new beta.1 trailingSlash option.

#3372
#4908

For GH pages we now recommend using trailingSlash: false as it will emit /x.html instead of /x/index.html and prevent GH pages to add that trailing slash, breaking relative links resolution.

See also https://github.com/slorber/trailing-slash-guide to understand how GH pages behave.

https://docusaurus.io/docs/deployment#trailing-slashes

As this is a new option, please let me know if false is a good value for GH pages. If it is a good setting fr GH pages, we may add a warning on docusaurus deploy so that people always use trailingSlash: false with GH pages. Your feedback is important so let me know.

@slorber slorber closed this as completed Jun 21, 2021
@F43nd1r
Copy link
Author

F43nd1r commented Jun 21, 2021

As this is a new option, please let me know if false is a good value for GH pages.

Yes.

If it is a good setting fr GH pages, we may add a warning on docusaurus deploy so that people always use trailingSlash: false with GH pages.

That would be nice, although I'm deploying with a dedicated github action which doesn't use deploy (https://github.com/ACRA/acra/blob/master/.github/workflows/deploy-docs.yml#L25)

@slorber
Copy link
Collaborator

slorber commented Jun 22, 2021

Thanks for the feedback.

For GH action deploy then we can't do anything apart from documenting it.

@F43nd1r
Copy link
Author

F43nd1r commented Jun 22, 2021

For GH action deploy then we can't do anything apart from documenting it.

Yeah, makes sense. Was just mentioning to say it won't affect me personally.
Thank you for the tip and replies 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: question This issue is a user error/misunderstanding.
Projects
None yet
Development

No branches or pull requests

3 participants