Hugo Static Site missing images once deployed to Cloudflare Pages

Hi everyone, Thank you for looking at this issue. I made a simple Hugo website locally, git pushed to GitHub, and deployed to Cloudflare Pages (https://williamsrestore.com/). I removed the base_url in hugo.toml and used the build commands of "hugo -b $CF_PAGES_URL" in Cloudflare pages. I attached an image showing that Cloudflare Pages uploaded the images (work1-4.jpg) but when I visit https://williamsrestore.com, the images are broken/not loading at the bottom of the website. Any advice on how to fix this? Thanks in advance.
12 Replies
Nob
Nob4mo ago
can you send the build logs ?
SendMost
SendMost4mo ago
The assets appear to be uploaded during build but I think they're incorrectly being referenced and thus breaking.
Chaika
Chaika4mo ago
Pages is case sensitive. You're referencing them in your html as .jpg lowercase, but they're uppercase https://williamsrestore.com/images/work2.JPG vs https://williamsrestore.com/images/work2.jpg It'll work on Windows because Windows is case-insensitive, but in other more sane systems it won't
Chaika
Chaika4mo ago
I would just lowercase the extensions/keep all filenames lowercase
SendMost
SendMost4mo ago
Yooo! Thank you. Good eye. I will test it.
Nob
Nob4mo ago
whats this image x)
SendMost
SendMost4mo ago
It's equipment for water damage restoration.
SendMost
SendMost4mo ago
I only have .jpg on my local environment but it is showing as uploading both upper and lower case... do I need to redeploy on cloudflare pages to remove the uppercase? i am still pointing to lower case but the images are still broken/not loading.
No description
Chaika
Chaika4mo ago
you don't really need both but that'll work. The only thing you're hitting now is cache
No description
SendMost
SendMost4mo ago
yes, i didn't intend to upload both. the github only has lowercase so it is the old cache as you say thank you!
Chaika
Chaika4mo ago
You could go to Caching -> Configuration -> Purge everything, or Caching -> Cache Rules to stop your website from caching Pages. Pages has its own internal cache, it's just that your Custom Domain will also cache images and certain extensions If you make a cache rule like this, you can stop that: (don't mind my text edit over someone I helped create this before, easier to reuse lol, same idea)
No description
SendMost
SendMost4mo ago
i absolutely love cloudflare. thank you for this information this cache rule is great and i now see the images. you're the best @Chaika thanks for your help too @Nob