Refer to static images from post

Continuing the discussion from Image path:

Given a baseURL set to https://example.com/hugo/, and I have an image static/img/image.png that I would like to access in a post inside the content folder.

This post advises us to avoid using links like

![This is an image](/img/image.png)

I tried the above Markdown code in a post, and got an 404 error since the generated image path is https://example.com/img/image.png instead of https://example.com/hugo/img/image.png.

So how can @stiobhart’s Markdown code be adapted to this case for displaying images under the static/img folder?

This will work fine for normal use.
I’ll let @alexandros comment on it’s use in a theme’s demo site.

Well I think that this syntax ![This is an image](/img/image.png) will still point to the host root since the site will be served from a subdirectory.

@VincentTam maybe it would it best if you used Page Bundles because only in that case will that markdown syntax image be relative to the content file.

1 Like

@alexandros Thanks for suggestion. However, the post shown in the screenshot has translations.

$ git grep workday.jpg
exampleSite/content/de/blog/coffee-ipsum.md:![Sample image](/img/workday.jpg)
exampleSite/content/en/blog/coffee-ipsum.md:![Sample image](/img/workday.jpg)
exampleSite/content/es/blog/coffee-ipsum.md:![Sample image](/img/workday.jpg)

Where should the image file be put in this case?


Edited: I figured it out. Either one Page Bundle will do. The non-page resources will be accessible across different languages with the same bundle path and name.