Hugo does not see static images

Hello, I read all the similar articles before posting this topic and none of the existing answers were able to help.

I’ve made a site for wiki, my hugo.toml is:

baseURL = 'https://sedyh.github.io/eui/'

I’m using module system, I guess its not that important, but module name is"

module github.com.sedyh.eui

I placed all my images in the static dir:

static/
└── images/
    └── hero.png

I made a new page:

content/
└── layouts/
    └── row/
        └── _index.md

Then I run hero serve.

The absoulte path is working fine:

![](http://localhost:1313/eui/images/hero.png)

But none of this works:

![](/eui/images/hero.png)
![](eui/images/hero.png)
![](/images/hero.png)
![](images/hero.png)
![](/hero.png)
![](hero.png)

As far as I know the correct one should be like images/hero.png, but it does not work just like all the other options.

I’ve clearly configured something incorrectly, but I can’t figure out what it is.

that one should work ![](/eui/images/hero.png) works.

With Hugo v123.0+ the most convenient method would be to turn on the embedded image render hook as described here:

add this to your hugo.toml

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

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

you now can refer to the images in /static/images/hero.png

![](/images/hero.png)
![](images/hero.png)

More details here:

2 Likes

Thanks a lot for the help!

The only option that works for me is:
module.mounts: static->assets + (/)images/hero.png

This does not work no matter what:
![](/eui/images/hero.png)

My hugo version if someone is interested:

hugo v0.135.0-f30603c47f5205e30ef83c70419f57d7eb7175ab+extended linux/amd64 BuildDate=2024-09-27T13:17:08Z VendorInfo=snap:0.135.0

believe me, that works - looks like a typo somewhere or refresh/cache issue (no way to check without sources)

but the render hook is the better solution anyhow

Ok. Thank you very much, this helped me a lot.
I guess I will use render hook now.

Btw, the sources are here, if you would like to check:

Some shortcodes also doesn’t seem to work like:

{{< code source="examples/bas_con_sin.txt" >}}

Which is:

start
{{ $language := .Get "language" }}
{{ $source := .Get "source" }}
{{ $options := .Get "options" }}

{{ with $source | readFile }}
{{ highlight (trim . "\n") $language $options }}
{{ end }}
end

Where readFile can’t find the path I guess?

Thats another problem.

The filename is based on the project root. So static/examples/... should do.

Details here
os.ReadFile | Hugo

Please consider opening new topics for new problems.

So static/examples/... should do.

Doesn’t seem to work in my case. I guess I did some configuration wrong?

Please consider opening new topics for new problems.

Ok, let’s discuss it here:

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