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

docs: set trailingSlash: false to fix refresh issues on GitHub pages #14

Merged

Conversation

haoqunjiang
Copy link
Contributor

Issue number of the reported bug or feature request: #13

Describe your changes

It's said (and as I tested) that if GitHub Pages detects that the URL points to a directory on the server, it will add a trailing slash to the URL when refreshing.
https://stackoverflow.com/a/33271505/2302258

Per Docusaurus's default configuration, docs/getting-started/overview.mdx would emit docs/getting-started/overview/index.html, therefore GitHub Pages would take docs/getting-started/overview/ as the canonical URL.

However, the relative links in the document are not touched by default, so ./alternatives remains ./alternatives, which is docs/getting-started/alternatives on the original web page, and docs/getting-started/overview/alternatives after refreshing. The latter would lead to a 404 page.

To fix this, we have to enforce a trailingSlash style.
trailingSlash: true requires fixing quite a few links across the docs, so I chose trailingSlash: false to keep as many links untouched as possible.

@haoqunjiang haoqunjiang requested a review from a team as a code owner October 9, 2024 08:20
Signed-off-by: Haoqun Jiang <[email protected]>

It's said (and as I tested) that if GitHub Pages detects the URL points
to a directory on the server, it would add a trailing slash to the URL
on refreshing.
<https://stackoverflow.com/a/33271505/2302258>

Per [Docusaurus's default configuration](https://docusaurus.io/docs/api/docusaurus-config#trailingSlash),
`docs/getting-started/overview.mdx` would emit `docs/getting-started/overview/index.html`,
therefore GitHub Pages would take `docs/getting-started/overview/` as
the canonical URL.

But the relative links in the document would not be touched by default,
so `./alternatives` remains `./alternatives`, which is
`docs/getting-started/alternatives` in the original web page, and
`docs/getting-started/overview/alternatives` after refreshing.
The latter would be a 404 page.

To fix this, we have to enforce a `trailingSlash` style.
`trailingSlash: true` requires fixing quite a few links across the docs,
so I chose `trailingSlash: false` to keep as many links untouched as
possible.
@tchetwin tchetwin force-pushed the docs-trailing-slash-off-for-github-pages branch from 65b585e to d9702f6 Compare October 9, 2024 15:22
Copy link
Member

@molisani molisani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad you caught this issue, and thanks for the fix!

@molisani molisani merged commit 86a5542 into bloomberg:main Oct 10, 2024
2 checks passed
@molisani molisani added the documentation 📝 Improvements or additions to documentation label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📝 Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants