Docusaurus: can use relative image path?

Created on 31 May 2020  ·  7Comments  ·  Source: facebook/docusaurus

❓ Questions and Help

i make a dir /doc/imgs/ directory, and doc/1.md link a image:

[](imgs/1.png)

but it not work , i see npm run build result, the imgs director does not copy to。

needs triage questions

Most helpful comment

Hey all, this is feature is now released!
If you like it, don't forget to retweet 😄
https://twitter.com/docusaurus/status/1286715187983048704

All 7 comments

You can try use the static folder. Check out our doc - static assets

@fanny
i think it's not very convenient,may below is ok

- docs
    - ios
        - imgs
        - x.md
        - y.md
    - android
       - imgs
       - x.md
       - y.md

Alternatively you can use <img src={require('relative/path/to/image')}>. Putting the docs relative path there wouldn't work because the paths aren't processed by our Markdown parser and the images within the docs directories aren't copied into the build folder, so the paths will be referencing a non-existent file.

Why can't we colocate our images with the Markdown files they belong to?

This means that I can't use the regular Markdown syntax for images (![hello](./myImage.png)) unless I put every image in the static folder? This is not very scalable if my docs site has many screenshot-heavy tutorials.

=> https://github.com/facebook/docusaurus/issues/3057

we should make this possible

Hey all, this is feature is now released!
If you like it, don't forget to retweet 😄
https://twitter.com/docusaurus/status/1286715187983048704

@slorber this is awesome! retweeted :)

Was this page helpful?
0 / 5 - 0 ratings