Skip to content

Support onBrokenMarkdownImages, ability to not fail the build in case of a broken image path #11219

@crackleeeessyp

Description

@crackleeeessyp

Have you read the Contributing Guidelines on issues?

Prerequisites

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: ![qrcode](../../../images/qr.png)

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 ![qrcode](/images/qr.png), 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

No one assigned

    Labels

    featureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions