Inserting images in Documentation doesn't work

I want to insert an image into my documentation markdown page in Julia. However, it does not respond to my HTML tag.

<img src="../../../src/assets/complex_plot.png" width="300" align="right"/>.

Also, if you open this link and press edit, you will see the image in a preview:
https://unfoldtoolbox.github.io/UnfoldMakie.jl/dev/

What could be a problem?
We use Literate and Documenter to create pages.

Thanks for linking the code, then I can hopefully directly help. The “problem” ist, that this is still considered Markdown in you md file, to mark that as html use a raw block as described in Syntax · Documenter.jl

The relative path might be a next problem, but that is not so easy to check without the image tag working.

Thanks! That is definitely a step forward! Now I see small image icons instead of tags.

However it couldn’t find the image. I tried:

```@raw html
<img src="../../../build/assets/complex_plot.png" width="300" align="right"/>
<img src="../../build/assets/complex_plot.png" width="300" align="right"/>
<img src="../build/assets/complex_plot.png" width="300" align="right"/>
<img src="build/assets/complex_plot.png" width="300" align="right"/>
<img src="../../../src/assets/complex_plot.png" width="300" align="right"/>

None of them worked


The link to a current version: https://unfoldtoolbox.github.io/UnfoldMakie.jl/previews/PR144/

That is what I expected and feared – so now your HTML is correct, but the relative path to the image does not work, the thing to have in mind (upon HTML inspection in my browser, thanks for the new PR link)

<img src="assets/complex_plot.png" width="300" align="right">

works since your index.html is in the main folder and then there is also direct the assets :slight_smile:

One thing to be aware of is the warning about prettyurls towards the end of of the “Building an Empty Document” section in the Documenter guide. In a nutshell, make sure to always use prettyurls=true, since the correct relative path will depend on the value of prettyurls.

Thank you very much! Now everything works!!! :star_struck:

Seems like I was too optimistic.
Got another problem using Literate

The resulting page: Plot Types · UnfoldMakie.jl

In a file plot_types.jl I wrote

# ```@raw html

# <img src="../../../src/assets/dimensions.jpg" width="300"/>

# ```

# ```@raw html

# <img src="../../src/assets/dimensions.jpg" width="300"/>

# ```

# ```@raw html

# <img src="../src/assets/dimensions.jpg" width="300"/>

# ```

# ```@raw html

# <img src="/src/assets/dimensions.jpg" width="300"/>

# ```

# ```@raw html

# <img src="assets/dimensions.jpg" width="300"/>

# ```

dimensions.jpg is located at the following URL.

https://unfoldtoolbox.github.io/UnfoldMakie.jl/previews/PR144/assets/dimensions.jpg

The URL for the page you linked is as follows.

https://unfoldtoolbox.github.io/UnfoldMakie.jl/previews/PR144/generated/intro/plot_types/

Thus the relative URL should be ../../../assets/dimensions.jpg.

2 Likes

It works! Thank you very much!