Markdown images get wrong url

Hello!
I have a page I´m making with hugo: GitHub - DJSAMSAM/samscorner

The problem is, when trying to insert an imgae, as in the draft post /content/posts/GS500.md the generated HTML sets the image source as
img src="[/images/blog/suzanne.png], when in reality, the image is at samscorner/images/blog/suzanne.png.

How do I make it so that it sets the correct image location based on my baseurl?

I must also clarify that this issue appears when using the “hugo server” command locally with the -D flag

You are serving your site from a subdirectory, which is fine, but this means that the host-relative URL to your image is /samscorner/images/blog/suzanne.png.

You could change your markdown accordingly, but if you change your hosting setup you would have to change all the markdown instances as well… this isn’t a great idea.

Instead, enable Hugo’s embedded link and image render hooks to properly resolve link and image destinations:

[markup.goldmark.renderHooks.image]
enableDefault = true

[markup.goldmark.renderHooks.link]
enableDefault = true

[[module.mounts]]
source = 'assets'
target = 'assets'

[[module.mounts]]
source = 'static'
target = 'assets'

See:

Thank you once again jmooring!

You resolved my issue!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.