rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
18.43k stars 1.65k forks source link

Images with relative path not displayed on index.html #2380

Closed J3rome closed 6 months ago

J3rome commented 6 months ago

Problem

Given the following folder structure :

- SUMMARY.md
- img/
  - image.png
- folderA
  - pageA.md
- folderB
  - pageB.md

The first entry in the SUMMARY.md point to [pageA](folderA/pageA.md)

I added image.png in pageA.md using a relative path like so :

![text](../img/image.png)

Once compiled, the images display properly when I navigate to /folderA/pageA.html (Which is where I am redirected when clicking on the section in the sidebar).

However, the images are not displayed on index.html which is pretty much a copy of /folderA/pageA.hml. The link to the image is still ../img/image.png. I would have expected the image link to be modified to img/image.png when the index.html was generated since it's one folder up in the hierarchy.

Am I doing something wrong ?

Steps

No response

Possible Solution(s)

No response

Notes

I also tested adding a link to another page using the following syntax

[link](../folderB/pageB.md)

The same behavior happen where the link on the index.html are not rewritten and are therefore broken.

Version

mdbook v0.4.37
ehuss commented 6 months ago

Thanks for the report! I believe this is a duplicate of #2060, so closing in favor of that.