-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Docusaurus v3 markdown links don't resolve correctly from index pages during build step when trailingSlash is set to false #9720
Comments
There is nothing at And trailingSlash has an impact on relative link resolution. I'm sorry but your sandbox does not match your text description, which makes things confusing. Please try again by having the text and the sandbox being in sync. For example your sandbox is using a relative path link (which we don't recommend because it's sensitive to trailingSlash setting changes) [Cool page](../test2/cool-page) While your text is using a relative reference to a markdown file [Cool page](../cool-page.md) Those 2 are not the same at all, and will not resolve the same. Most likely it's a mistake on your side, so I'm closing as can't repro. The behavior you see in your sandbox is the expected behavior. |
The bug works the same regardless of the location of the page being linked. However, I've updated my repro to match the bug /exactly/. |
Just saw the note about adding .md extensions. I'll use that. Thank you |
I'm still seeing this bug if an image links to a markdown file. This fails claiming the link is broken:
As soon as I switch it to a text link, it works despite having the same link path. I've updated the repro project here: https://codesandbox.io/p/devbox/runtime-pine-84xm8d |
Can confirm the bug, related to resolving relative file paths when using an image. Can reproduce this on our own website: [text](./installation.mdx)
[![alt](/img/slash-introducing.svg)](./installation.mdx) Only the first link resolves. Definitively a bug. Track #9048 for the root cause and the solution. We can keep this issue closed. |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and 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-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 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
The text was updated successfully, but these errors were encountered: