Hi, i’m new to hugo. I put a .jpg file in a folder called img inside the static folder, like so:
static/img/image.jpg, and in my post I did but on the site the image doesn’t show. There’s a broken image there.
How can i solve this?
Welcome,
First of all, it would be very useful to point us to your repository to understand your caode.
Second, I don’t at all understand
in my post I did “erorlog”
which has nothing to do with an image…
Sorry. My repository: here
What I meant was that I typed the line:
in the second post.
Also please ignore the gallery images, that was another way of displaying images I failed to use.
Also, here’s the blog site: here
You are serving your site from a subdirectory:
https://github.com/Coosis/blog/blob/51713c51448b18ff58b277c8a52324b0cbc23e80/hugo.toml#L1
So /img/foo.jpg
doesn’t resolve to what you want.
The easiest way to handle this is by keeping your images with your page (a page bundle).
content/
└── posts/
├── post-1/
│ ├── foo.jpg
│ └── index.md
└── post-2.md
markdown
![alt](foo.jpg)
Stupid question: How do i create a page bundle? Do i just manually put them in a folder? What should i write in index.md?
hugo new content posts/post-1/index.md
That’s where your markdown content goes. For example, instead of creating post like content/posts/lorem-ipsum.md
you create content/posts/lorem-ipsum/index.md
. Then you can put all your images for that page inside the lorem-ipsum
folder and refer to them in your index.md
file. The command shared by Joe simplifies all this for you.