How to prevent creating duplicated image with different name? #49
-
Sorry for the vague title. All images in my site are either WebP or SVG, except for few exception that I can't control. I recently found out that, when my site is built, there are two image files that have same size but different name present. ![](001.webp) If I use this syntax, there would be two identical files generated like this: I downloaded these two images for file size comparision, but they had same file size. I know that serving file with hash in its name (a.k.a. hashed) will ensure the viewer will always have correct image, even if the site is behind Cloudflare CDN which caches images from their side. But having two identical image eats up server storage, and Cloudflare Pages limitation. Recently, I migrated my site from Cloudflare Pages to dedicated server, which is much slower than CF Pages', because my site is rejected from them. The build result had too many files and exceeded Cloudflare Page's 20,000 files limitation. I think this behavior ― having hashed and unhashed file together ― ate up Cloudflare Page file limit. In my theory, you'll catch up CF Pages file limitation with 100 posts that each post have 100 images in it.
First, I suspected imports:
#- path: github.com/hugomods/images
But it didn't changed anything. Since my custom shortcodes rely on it, Hugo should fail to serve or build site, but it didn't. Site were built without any problem, and the generated site still had two same file, hashed one and unhashed one. When I run
In this case, disabling Of course, I might be able to create a script that deletes every unhashed files blindly. But this might break the site if there was any reference to unhashed file. My shortcodes rely on I think letting Hugo (and Or, if
So, can you do either one of these?
Or, any idea for way of safely remove unreferenced unhashed files from build result. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
No, I think the problem is that all page resources will be published by default, so you will got duplicated resources, disable it should work. // config.yaml
cascade:
- _target:
kind: page
path: /*/**
_build:
publishResources: false I'vent test, tweak it to suit your needs. See |
Beta Was this translation helpful? Give feedback.
No, I think the problem is that all page resources will be published by default, so you will got duplicated resources, disable it should work.
I'vent test, tweak it to suit your needs.
See