Image showing in markdown but not in actual website(server)

As the title says, my png image shows fine on markdown preview on VS Code, but when I actually run the server, the image won’t render. It only shows the temporary text, and when I try to open the image in a new tab via right clicking, it returns a 404 error.

I think this may be a bug since, as I previously mentioned, on VS Code the image shows fine without any problems. So I think that means the problem is not the directory, but something with the compiler or the renderer. Unless there is something that I don’t know?

Regardless, I’ve tried too google and fix it myself by

  • changing the image directory from static to static/images
  • changing the image directory to local(where the markdown post is)
  • using the {{ $image := .Resources.GetMatch "image.png" }} (yes, I changed the image name)
    with no change in results.

I would like to attach screenshots, but it is a post with semi-advertising(it’s about a game asset that I made), so I thought people wouldn’t like it. but I will if anyone finds it necessary.
(edit: temporary github repo is GitHub - whatthesamuel/hugo_website: hugo website code)

Using the PaperMod theme, but I don’t think it is a theme-related issue.

happens in hugo version 0.96.0

hugo v0.96.0-2fd4a7d3d6845e75f8b8ae3a2a7bd91438967bbb windows/amd64 BuildDate=2022-03-26T09:15:58Z VendorInfo=gohugoio
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.18"

(edited to better fit getting help guidelines)

You are more likely to receive a prompt and accurate response if you post a link to the public repository for your project.

See https://discourse.gohugo.io/t/requesting-help/9132.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

I edited the original post to add the link to the repo, thank you.

No:

![preview](/static/images/GM-CLI.png)

Yes:

![preview](/images/GM-CLI.png)

https://gohugo.io/content-management/static-files/

3 Likes

oh wow, I guess I misunderstood how the entire thing works. Thanks for the help!

1 Like

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