I’m trying to use Hugo to write a blog and the SVG images are missing both when served locally and on GitLab pages. On GitLab, the CI pipeline is successful, no errors are shown, also when I run locally
hugo --debug --disableFastRender --path-warnings -v serve
I do not get any errors. My images are placed in static/img/pytorch-sequential-cpp and are refered to using Markdown in the post as
and it didn’t help. I have read on this forum that I can organize static sub-folders however I want, so I guess the problem is not with the sub-folders. I also tried putting the images directly in static and also in static/img, nothing works.
The img is already in static, the final subfolder is static/img/pytorch-sequential-cpp, this is where I keep the images of the pytorch-sequential-cpp post. I tried img/... and /img/... in the Markdown link and nothing changes. I’ve read about the static folder in the documentation, so I’ve used it acordingly.
Your page tries to load the image at https://tmaric.gitlab.io/blog/posts/pytorch-sequential-cpp/img/pytorch-sequential-cpp/nn-64-64-Ns1000-Ne1000-Adam001.svg.
(Right click into the page, last point in the menu should be something like inspect and you can see the browser console.)
When I hover over the URL in that link (the second SVG image on that page) then it shows a gitlab URL. You have some kind of URL rewriting going on. Check what Gitlab is saying in it’s documentation about Resources hosted there. I never used it.
For the rest: the slash in front and the img dir in static should do the trick after that is fixed.
I was experimenting with /img and img, and putting the images in content as well, and nothing worked. You can see the links of other images, they all use /img/... I’ve changed the first one now as well and pushed, no image is shown… Trying to use the “inspect”… never debugged a website… Thanks for the help btw!
Does the fact that the site is served from tmaric.gitlab.io/blog impact hugo serving the site locally? Because the images are also missing when I do hugo serve locally…
Would this make things easier if I change the domain and the subfolder is not used anymore? Otherwise I guess I would have to go over all posts and remove /blog from all /blog/img/... instances.
Page bundles are working great. I’ll stick to them, then I don’t have to think so much about where the images are relative to the posts, and I have them in the same folder as markdown files which is nice.