Confused with where to put static image

I am learning hugo and gradually realizing it is a fantastic tool. But I got confused with static image and hopefully someone can help me.

In my draft post, I have this line:

![Learn Chinese](/static/img/is-chinese-hard-to-learn.png)

Then I created a folder called img under static and put the file is-chinese-hard-to-learn.png in.

However, when I run hugo server -D, the image is not rendered (returns 404)

What am I doing wrong here?

Many Thanks

Image from static/img/ should be available at http://localhost:1313/img/is-chinese-hard-to-learn.png and it does not depend on the link in the draft.

1 Like

I fixed the formatting of the link example in your post. Don’t link to /static/img/whatever.png, but rather do it like this:

 ![Learn Chinese](/img/is-chinese-hard-to-learn.png)

That’s because the content of /static represents the root of your published site. Your content needs to omit /static from any path.

Also, my understanding is that in the most recent release (v0.32), there is now support for bundles, which means your image file can live in the same directory as your post.

So if you have a directory that contains a .md file, and you want to link to your image, you could write it as ![Lear Chinese](/folder-with-file/is-chinese-hard-to-learn.png). It depends on how nested your .md file is compared to the content/ directory.

Someone correct me if I’m wrong, but I got this to work for me last night.