Duplicated untranslated images in multilingual site

I have a website hosted on Github pages, where storage space is limited to 1 GB. The website is multilingual. Translations go in language subfolders.

defaultContentLanguageInSubdir = true
canonifyURLs = true
removePathAccents = true

[languages]
  [languages.en]
    languagename = "English"
    weight = 1
  [languages.fr]
    languagename = "Français"
    weight = 2

Some images (app screenshots) are translated (using .en.jpg or .fr.jpg as extensions). Most of them are not (using .jpg as extension).

These images use responsive sizes (HTML <img src=" " srcset=" " sizes=" "). The srcset` sequence of images is computed by Hugo:

{{ $image = resources.Get $src }}
{{ $set := slice }}
{{ range slice 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 }}
      {{ if lt . $image.Width }}
           {{ $size := print  . "x" .}}
           {{ $thumb := $image.Fit $size }}
           {{ $set = $set | append (printf ("%s %dw") $thumb.RelPermalink $thumb.Width ) }}
      {{ end }}
{{ end }}
{{ if gt (len $set) 0 }}
    {{ $srcset = delimit $set ", "}}
{{ end }}

My problem is that non-translated images are duplicated in both /en/ and /fr/ language directories, using storage space for nothing. How could I prevent that ?

Ok, me stupid. I’m still on v0.122.0. The doc says v0.123.0 makes it happen by default. Google is just not aware of it yet.

BTW, that makes the whole website go down from 468 MB to 56 MB… That’s what I call development going in the right direction. Kudos guys !

1 Like

Correction, 56 MB was because of this issue : Hugo 0.123: module is not imported anymore.

After solving it, the website size is 168 MB, which is still a 64% saving compared to 0.122.

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