Image path with relative URLs

a very simple question but I couldn’t find an answer.
I have this structure:

 - images
   |- myimage.png

With pretty Urls, “mytopic” lands in the following page:
So I need to reference the image as:


The image location is ../images/myimage.png instead of ./images/myimage.png.
However this is pretty annoying because it doesn’t corresponds to the real folder structure.
So rendering the markdowns with other tools (github, pandoc etc.) will not work.
Any idea?

1 Like

Pretty URLs are something else.

You are talking about relative URLs.

In my opinion it is not a good idea to reference images in the form you posted above.

It is preferable to keep the images next to the content file, so that image previews work in other Markdown editors.

I tried to place the image next to the content file:

 - myimage.png

But this still doesn’t work because the document lands in while the image is at
The only thing that works is:

 - mytopic
   |- myimage.png

In this case yes, I can reference my image locally.
However, I am developing a documentation with many sections, each sections is a markdown file. It seems heavyweight to create a folder for each section.

Have a look at this similar topic:

Thanks, so I guess the short answer is “not possible”.
The only way I see is to activate “Ugly URLs”.
In this case the markdown file is rendered as So the image can be referenced locally.

I’m trying another approach to build the website:

  • I’ll put all my document sections in the same file This will allow to reference locally the images.
  • the top menu will use Hugo menu system: {{ range .Site.Menus.main }}
  • the side menu will use Hugo table of content: {{.TableOfContents}}

Although I like to split documentation in many files, I don’t think Hugo supports that very well (no table of content, broken image paths).

You may want to track

A post was split to a new topic: Documents posted on GitHub looks different from rendered by Hugo