Using images with Hugo

43 Views Asked by At

I am building a Hugo website and I want to include images in content files. This is documented of course but it still is unclear to me how this works.

Creating a link to another page is easy enough using relref.

[Link to my page]({{< relref "mypage" >}} "Whatever")

I expected inserting an image similarly easy but that is not the case. First attempt was to try

![alt text]({{< relref "myimage.png" >}} "image Title")

This does not work because relref is only for pages not images. It seems. It will fail each time with message that the page cannot be found.

The documentation mentions relLangURL but there is no built-in shortcode for it, so that is also a dead end.

We can of course not use shortcode, put the image in static, and just write something like

![alt text](myimage.png "image Title")

That will work but that IMHO is sort of defeating the purpose of using a tool like Hugo in the first place. For example I want to publish various versions of my website with different base URL's. When links are not generated by Hugo this will cause broken or wrong links.

Is there really not support for adding simple images in Hugo??? I am running the latest version v0.111.3. I find it hard to believe that support for adding simple images is still being worked on. For example there is some support for adding diagrams for example Mermaid diagrams. Why is the community working on diagrams when there currently is no support for adding a simple image?

0

There are 0 best solutions below