Image path of the publish site is different from content folder markdown file

I have a set of image in content/zh-tw/post/Blockchain and my deploy blog doesn’t render it.

However, the markdown file content/zh-tw/post/Blockchain/LikeCoin Analysis.md successfully render the image.

I found that the public/zh-tw/p/likecoin-經濟模式透明度與創作者收入穩定性探討/index.html is getting the wrong image dir so my image doesn’t render

<p><img src="/Wonderland/image.jpg"
	
	
	
	loading="lazy"
	
	
></p>

I wonder there might be something wrong with my deployment but I copy the workflow from Host on GitHub Pages , how can I fix the image dir and get my image render correctly? The image should be rendered as page resource.

I don’t want to fix every image link in the public/ because it will be a huge work. And the similar topic I found is having a different version I am using, so I am starting a new topic.

What version of Hugo are you using (hugo version)?

$ hugo version 145.0

Does this issue reproduce with the latest release?

No

when you have ![](image.jpg) it means that the compiler is going to assume that the image is in the same directory as the content file. In this case, the compiler will assume that the image is located at /zh-tw/post/Blockchain/LikeCoin Analysis/image.jpg which will return a 404.

you can either fix this by linking the images with a / so it would be ![](/image.jpg) or store all the static images in /static/ directory.

I personally always use the /static/ to store all the media files like images, videos, logos, favicons.

hope this helps!! <3

Sorry, it doesn’t work.

Here is my file dir:

Here is the folder of my publish site:

either ![](/image.jpg) or ![](./image.jpg) will turn to <img src="/image.jpg"> and it will return a 404

This is your existing structure:

content/zh-tw/post/Blockchain/
├── LikeCoin Analysis.md
├── LikeCoin Test.md
├── _index.md
├── image.jpg
├── image.png
└── image.svg

The images are resources for _index.md, not for either of the other Markdown files.

If you want LikeCoin Analysis.md to have page resources, it must be a page bundle.

content/zh-tw/post/Blockchain/
├── LikeCoin Analysis/
│   ├── image.jpg
│   └── index.md
├── LikeCoin Test.md
├── _index.md
├── image.png
└── image.svg

It works now, thank you very much!

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