-
-
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
Links that contain spaces have to be enclosed in pointy brackets (<>) according to the CommonMark specification (see here). In Docusaurus, the links are displayed properly, but are routed to the original filename (i.e. they also keep the original file extension). A link such as [Link](<./file 1.md>) will go to https://<yourwebsitehere>/<yourpathhere>/file%201.md if onBrokenLinks is set to warn and will completely fail the build process otherwise.
Reproducible demo
Steps to reproduce
- Create a file with a space in its name.
- Link to it using a Markdown link (do not forget to properly enclose it in pointy brackets).
- (Optional) Set
onBrokenLinkstowarnindocusaurus.config.js. - Build the website and try the link, or observe the error.
Expected behavior
Build succeeds if onBrokenLinks is not set to warn, link works properly otherwise.
In the linked reproduction, links 2 and 3 should go to https://vladnastase.github.io/docusaurus-bug/chapter1/doc%202 and https://vladnastase.github.io/docusaurus-bug/chapter%202/doc1 respectively (instead of https://vladnastase.github.io/docusaurus-bug/chapter1/doc%202.md and https://vladnastase.github.io/docusaurus-bug/chapter%202/doc1.md)
Actual behavior
Build fails if onBrokenLinks is not set to warn, links don't work properly (they keep the original file extension).
Your environment
- Public source code: https://github.com/VladNastase/docusaurus-bug
- Public site URL: https://vladnastase.github.io/docusaurus-bug/
- Docusaurus version used: 2.4.0
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Chrome 111, Node.js 16.17.1
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): Ubuntu 22.04.1 LTS
Self-service
- I'd be willing to fix this bug myself.