Have you read the Contributing Guidelines on issues?
Prerequisites
Description
Hey all,
(My original issue was closed because my repro didn't match /exactly/. This one matches /exactly/.)
I've got a fresh docusaurus v3 project with trailingSlash set to false in the config, and I noticed that when it resolves relative links from markdown files, it does it incorrectly if the file is a readme.md file within a folder (acting as an index).
In short if you have the following docs folder structure:
docs/test/readme.md
docs/cool-page.md
and test/readme.md contains the following markdown:
[Cool page](../cool-page.md)
running build will generate the following error:
Exhaustive list of all broken links found:
- Broken link on source page path = test:
-> linking to ../cool-page (resolved as: /cool-page)
Despite the error saying it was resolved as /cool-page it is in fact not.
Interestingly, if I switch the link to ./cool-page (removing the ../). It works correctly. My guess is that rather than using the path of the readme.md file when resolving a relative path, it's using the location of the folder that contains it (in this case it assumes the links are coming from a file at the path ./test instead of a file at ./test/readme.md.
Max
Reproducible demo
https://codesandbox.io/p/devbox/runtime-pine-84xm8d
Steps to reproduce
run npm run build on the playground
Expected behavior
It builds correctly without errors
Actual behavior
Exhaustive list of all broken links found:
- Broken link on source page path = test:
-> linking to ../cool-page (resolved as: /cool-page)
Your environment
- Public source code:
- Public site URL:
- Docusaurus version used: v3.1.0
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Node 18
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS Sonoma
Self-service
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clearoryarn clearcommand.rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages.Description
Hey all,
(My original issue was closed because my repro didn't match /exactly/. This one matches /exactly/.)
I've got a fresh docusaurus v3 project with trailingSlash set to false in the config, and I noticed that when it resolves relative links from markdown files, it does it incorrectly if the file is a readme.md file within a folder (acting as an index).
In short if you have the following docs folder structure:
docs/test/readme.md
docs/cool-page.md
and test/readme.md contains the following markdown:
running build will generate the following error:
Despite the error saying it was resolved as
/cool-pageit is in fact not.Interestingly, if I switch the link to
./cool-page(removing the../). It works correctly. My guess is that rather than using the path of the readme.md file when resolving a relative path, it's using the location of the folder that contains it (in this case it assumes the links are coming from a file at the path./testinstead of a file at./test/readme.md.Max
Reproducible demo
https://codesandbox.io/p/devbox/runtime-pine-84xm8d
Steps to reproduce
run
npm run buildon the playgroundExpected behavior
It builds correctly without errors
Actual behavior
Exhaustive list of all broken links found:
-> linking to ../cool-page (resolved as: /cool-page)
Your environment
Self-service