Repository navigation
Closed
Labels
featureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.
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
Docusaurus build fails when referencing root-domain images via relative paths, despite setting baseUrl and onBrokenMarkdownLinks: "warn".
settings:
baseUrl: https://test/websites/my-docusaurus-site
Desired image URL: https://test/images/qr.png
Markdown reference: 
Error:
Module build failed (from ../node_modules/@docusaurus/mdx-loader/lib/index.js):
Error: MDX compilation failed for file "docs\intro.md"
Cause: Image ../../images/qr.png used in docs/intro.md not found.
Details:
Error: Image ../../images/qr.png used in docs/intro.md not found.
at ensureImageFileExist (\node_modules\@docusaurus\mdx-loader\lib\remark\transformImage\index.js:84:15)
at async getImageAbsolutePath (\node_modules\@docusaurus\mdx-loader\lib\remark\transformImage\index.js:106:5)
at async processImageNode (\node_modules\@docusaurus\mdx-loader\lib\remark\transformImage\index.js:129:23)
at async Promise.all (index 1)
at async \docs\node_modules\@docusaurus\mdx-loader\lib\remark\transformImage\index.js:148:9
at compileToJSX (node_modules\@docusaurus\mdx-loader\lib\utils.js:93:15)
at async loadMDX (\node_modules\@docusaurus\mdx-loader\lib\loader.js:22:20)
at async Object.mdxLoader (\node_modules\@docusaurus\mdx-loader\lib\loader.js:156:24)
I try to use , however, it does not point to the website root, so I can only use ../../../images/qr.png to make sure its url is https://test/images/qr.png.
Any idea to solve this problem?
Reproducible demo
No response
Steps to reproduce
Simple docusaurus starter project can produce above issue
Expected behavior
Ignore validations in markdown file because I already set onBrokenMarkdownLinks to warning
Actual behavior
It still validate url in markdown for images
Your environment
- Public source code:
- Public site URL:
- Docusaurus version used:
- Environment name and version (e.g. Chrome 89, Node.js 16.4):
- Operating system and version (e.g. Ubuntu 20.04.2 LTS):
Self-service
- I'd be willing to fix this bug myself.
Metadata
Metadata
Assignees
Labels
featureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Activity
slorber commentedon May 30, 2025
It's impossible to help without a docusaurus.new repro, we don't even know where your image file is exactly. Please provide a repro and respect our issue template, providing all the required information. I'll reopen if a repro is provided and we can clearly validate it's a bug.
onBrokenMarkdownLinkshas no effect on markdown images. Images are not links. We validate images by default but if you want an escape hatch you can use, in which case we output the path provided directly in the HTML markup. If the image doesn't exist at the path you provide, we can't do anything about it, it's out of the scope of Docusaurus.scooby359 commentedon Jun 3, 2025
A markdown image using the syntax
is still using a link as the image source. Would expectonBrokenMarkdownLinksvalue to be respected here too.slorber commentedon Jun 4, 2025
A markdown image is not a markdown link, despite using a similar syntax. Similarly, a
<a href"">is not the same as<img src="">, despite both using an URL.We are more likely to introduce a new
onBrokenMarkdownImagesAPI rather than emit image URLs inonBrokenMarkdownLinks. Would that be helpful?(in the future, all these APIs are likely to accept a callback and not just a severity level)
scooby359 commentedon Jun 4, 2025
Yes, handling these broken elements is important to the user experience - it's handled for links and anchors, so reasonable for users to expect it would handle images with the same problem too.
My experience of this is that I'm looking at migrating an Obsidian markdown project to Docusaurus so it can be web hosted, but this will be a gradual project as content needs to be verified as safe to publish. In the meantime, this causes broken images. Currently, Docusaurus refuses to build at all where image paths are broken, so it's not fit for use for my project.
Having Docusaurus be able to handle broken image paths would make it easier to migrate projects into Docusaurus.
crackleeeessyp commentedon Jun 6, 2025
How about reopen this issue, since it will block build process if the resources not in the local, and wish there is another configuration to make it work.
slorber commentedon Jun 6, 2025
I'm going to reopen and consider this a feature request to add
onBrokenMarkdownImagesBut you are not blocked, if the resource does not exist locally, you can:
pathname://so that we leave your resource URL unchanged (escape hatch, but you might depoy broken images to production)https://example.com/myimage.pnginstead of/myimage.png)Unlike links, we use
require('./image/path.png')for images, so if we stop throwing for such images, then we'll have to output your path as is, and no image will be processed by the bundler (like we usually do for all local images).[-]onBrokenMarkdownLinks not work for image links in mdx file[/-][+]Support `onBrokenMarkdownImages`, ability to not fail the build in case of a broken image path[/+]slorber commentedon Jun 6, 2025
Honestly I'm not sure to understand your point.
Docusauus protects you from deploying a site with broken images. If you migrate, this is a nice feature that permits to explicitly tell you that you may not have migrated all your images properly. If you use this flag, you will be able to deploy, but your site will show missing images, and I'm not sure it's better than forcing you to ensure the images are present. It's a DX feature to allow you to do so, not an UX feature (because website visitors will see broken images).
Edit: someone reported a case similar to yours here and this kind of makes sense, you may want to avoid the error overlay in dev, and be able to deploy a site with broken images in a staging environment.
slorber commentedon Jun 11, 2025
Until we add support for this, here are some ideas you can try implementing in userland.
#11247 (reply in thread)