Skip to content
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

Linking to images in docs broken when there is baseUrl #861

Closed
cckellogg opened this issue Jul 19, 2018 · 1 comment
Closed

Linking to images in docs broken when there is baseUrl #861

cckellogg opened this issue Jul 19, 2018 · 1 comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@cckellogg
Copy link

🐛 Bug Report

Document image links are broken when the site has a baseUrl. Instructions for linking to images within documents are here https://docusaurus.io/docs/en/next/doc-markdown#linking-to-images-and-other-assets. However, this does not work when the site has baseUrl other than "/".

To Reproduce

  1. Create an assets folder within the docs folder and add an image there
  2. Add a new document and link to that image (https://docusaurus.io/docs/en/next/doc-markdown#linking-to-images-and-other-assets)
  3. Add a baseUrl to the siteConfig (/test/)
  4. yarn start

Expected behavior

Then image should show up.

Actual Behavior

The image does not render.

Reproducible Demo

Here is an example project showing how the image link is broken when a baseUrl is provided in the siteConfig.

https://github.com/cckellogg/tmpscratch

@endiliey endiliey added the bug An error in the Docusaurus core causing instability or issues with its execution label Jul 20, 2018
@endiliey
Copy link
Contributor

endiliey commented Jul 20, 2018

Thanks for reporting this. Seems like a misleading documentation

Actually we should refer it to (assets/ and we will replace it to {baseUrl}/docs/assets/
https://github.com/facebook/Docusaurus/blob/22f3a85a494ddf46bc29964a7989335a7dba4a9a/lib/server/docs.js#L79-L83

The RAW Markdown is below:
https://github.com/facebook/Docusaurus/blob/master/docs/api-doc-markdown.md
correct-documentation

It got transformed into {baseUrl}/docs/assets/ in the website
wrong-documentation

Suggested workaround:

  1. Link your images by using /test/docs/assets/
    or
  2. Link your images by using /assets/
    or
  3. Place your images in /website/static/img and link to it with ![my image]({baseUrl}/img/your-image.png)

facebook-github-bot pushed a commit to facebook/flipper that referenced this issue Apr 2, 2020
Summary:
When using baseUrl in site config, it adds a prefix to all link paths.

But for assets, it doesn't work if you refer to them as `docs/assets/...`, you have to use just `assets/...`. Source: facebook/docusaurus#861

Reviewed By: passy

Differential Revision: D20796933

fbshipit-source-id: 2346e42b8b548f576a1e143f56ee5236eab55073
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

No branches or pull requests

2 participants