Duplicate Page Resources files in Multilingual Environment

Pages Resources in a Multilingual environment systematically duplicates identical resources in every languages page’s path.

This poses two problems for me:

  1. Visitor switching languages cannot benefit from browser cache.

    As most static site do not bother (rightly so) to redirect visitor according to browser preferred language, many visitors end up landing on the default site’s language and then switch to their own. Thus loading both versions of an identical resource.

  2. Takes x{NumberOfLanguages} as much space on disk. For me it’s not that big of a deal, but on projects with a lot of content, many languages, and a lot of server monitoring involved, this could become one.

I’m not sure anything can be done on the Hugo implementation as I suppose this behaviour is in place for a reason.
And I understand in many cases those resources, though baring the same name may differ. Some thumbnails will differ by languages for example.

But in a context when you know for a fact that the resource is unique to every languages, I wonder if there is a way so, even though both resources will likely be created on disk, only the permalink of the default’s language one is ever printed.

This is what I got so far:

{{ $original := . }}
{{ if not (eq .Lang "en") }}
	{{ range .Translations }}
		{{ if eq .Lang "en" }}
			{{ $original = . }}
		{{ end }}
	{{ end }}
{{ end }}
{{ $featured := $original.Resources.GetMatch "**feature*" }}