-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I'm using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - I have tried
rm -rf node_modules yarn.lock package-lock.jsonand 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
The broken link checker sometimes requires a trailing slash and sometimes it works without it.
The fix is then to do
[reported link]: /docs/test#abc
[working link]: /docs/test/#abcReproducible demo
No response
Steps to reproduce
You can reproduce it in our docs repository: https://github.com/21TORR/docs
-
check it out
-
run
pnpm install -
go to this file https://github.com/21TORR/docs/blob/live/docs/php/tooling/janus-php.mdx and change the links:
- [Composer bin plugin]: /docs/php/tooling/#composer-bin-plugin + [Composer bin plugin]: /docs/php/tooling#composer-bin-plugin ... - [the note about it]: /docs/php/tooling/#phpunit + [the note about it]: /docs/php/tooling#phpunit
-
run
pnpm build
And you will get the error:
Exhaustive list of all broken anchors found:
- Broken anchor on source page path = /docs/php/tooling/janus-php:
-> linking to /docs/php/tooling#composer-bin-plugin
-> linking to /docs/php/tooling#phpunit
Expected behavior
I am not very familiar with the age old issue of trailing slashes and their handling in Docusaurus. But the pages themselves are accessible without trailing slash, so I would assume that the broken link checker would then just normalize the linked page before checking?
Or are there cases where these links will actually 404?
Actual behavior
The links are reported as issues, even if copying the link and pasting it into the browser works flawlessly.
Your environment
- Public source code: https://github.com/21TORR/docs
- Public site URL:
- Docusaurus version used: 3.3.2
- Environment name and version (e.g. Chrome 89, Node.js 16.4): the build is run on Cloudflare Pages with Ubuntu 22.04.2 and Node 18.17.1
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): see above
We have a public repository that I could share, however I fixed all the cases there. I will look at reproducing the issue however.
Self-service
- I'd be willing to fix this bug myself.