Prevent MyST from changing .md image paths

221 views Asked by At

I'm generating sphinx documentation with.md files that reference images via relative paths:

![](../_static/figures/image.png)

I use MyST to parse the .md files into html, but it removes the ../' making all paths:

_static/figures/image.png.

The relative paths work fine before documentation generation and has to kept the same. In the conf.py for sphinx I copy over the images as html_static_path files, and if the path is kept the same in the html, the images would show.

The MyST docs state that it copies .md images but give no configuration options for copying. The paragraphs below only reference how to parse HTML files with images. I did find another option that should treat all links as hyperlinks, but this made no change.

How do I force MyST to not change the image paths?

1

There are 1 answers

1
Lex Li On

I think it is more of a convention question.

It is recommended to put _static in all folder levels and separate assets like images inside each of them, so that links like _static/figures/image.png resolve to just that folder level.

If you want to use a single top level _static folder for all folder levels, then your links should be written as /_static/figures/image.png, where they are resolved to the top level.