-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Relative links break when imported / transcluded from other markdown files #3927
Comments
This is something I might be able to look into myself in the new year. Putting this here to keep track of it, and in case anyone has any pointers where I should start looking. |
Thanks for reporting this. Are you sure this exact error is obtained by running a build on your exact repro code? Relative links are added as-is to the browser, so depending on where your partial is required you might end up with this relative path being resolved differently. It is always resolved against the current URL, we don't do anything about it. To make things work reliably, you'd better use the relative md file path. It will resolve against the slug of the target document, keeping the version part of the URL (ie the user will stay in the same version when navigating from source to target) |
Aha! Thanks @slorber using the filename does indeed seem to fix it - I hadn't made the connection that they would be treated differently, and what you say about unchanging links makes sense. Fwiw, I re-ran the build on that unchanged commit and it does still fail. I'll leave it up to you to decide what to do with this issue, but it's not urgent, especially since using files sounds like a perfectly reasonable alternative. |
Let's keep it open for now, will see some day if I see the reason it fails on that repro, but yes, using relative md file paths is the best solution from linking docs between each others across a given version |
Going to close this now, because our doc strongly encourage to use absolute links or relative md file paths. Relative paths are not processed in any way by docusaurus, and it's your responsibility to make sure that the final relative link will work in the final page that includes the partial. Not 100% related but we added a more consistent support for the _ prefix, mostly for MDX partials: #5173 |
🐛 Bug Report
We can transclude markdown files within others by importing them and using them as JSX.
If the transcluded file contains a relative link, e.g
[Link](../target)
, then depending on which file imports it, it will fail.Interestingly, importing it works in some files, but not in others, I haven't quite figured out the exact conditions that determine this though, but I have a repro for the failing case.
Have you read the Contributing Guidelines on issues?
Yes
To Reproduce
Checkout jknoxville@e8ad7c1
yarn build
inside the website dir.Expected behavior
I expect the build to succeed, and /docs/api/plugins/ to contain a link to /docs/cli
Actual Behavior
yarn build
fails.However, when using
yarn start
and loading localhost:3000/docs/api/plugins/ directly from the URL, the link does work.Your Environment
Reproducible Demo
jknoxville@e8ad7c1
The text was updated successfully, but these errors were encountered: