Fix Resource output in multihost setups

In Hugo 0.46 we made the output of what you get from resources.Get and similar static, i.e. language agnostic. This makes total sense, as it is wasteful and time-consuming to do SASS/SCSS/PostCSS processing for lots of languages when the output is lots of duplicates with different filenames.

But since we now output the result once only, this had a negative side effect for multihost setups: We publish the resource once only to the root folder (i.e. not to the language "domain folder").

This commit removes the language code from the processed image keys. This creates less duplication in the file cache, but it means that you should do a `hugo --gc` to clean up stale files.

Fixes #5058
This commit is contained in:
Bjørn Erik Pedersen
2018-08-13 11:01:57 +02:00
parent c09ee78fd2
commit 78f8475a05
12 changed files with 225 additions and 44 deletions

View File

@@ -53,6 +53,10 @@ type Paths struct {
PublishDir string
// When in multihost mode, this returns a list of base paths below PublishDir
// for each language.
MultihostTargetBasePaths []string
DisablePathToLower bool
RemovePathAccents bool
UglyURLs bool
@@ -135,6 +139,15 @@ func New(fs *hugofs.Fs, cfg config.Provider) (*Paths, error) {
absResourcesDir = FilePathSeparator
}
multilingual := cfg.GetBool("multilingual")
var multihostTargetBasePaths []string
if multilingual {
for _, l := range languages {
multihostTargetBasePaths = append(multihostTargetBasePaths, l.Lang)
}
}
p := &Paths{
Fs: fs,
Cfg: cfg,
@@ -154,12 +167,13 @@ func New(fs *hugofs.Fs, cfg config.Provider) (*Paths, error) {
themes: config.GetStringSlicePreserveString(cfg, "theme"),
multilingual: cfg.GetBool("multilingual"),
multilingual: multilingual,
defaultContentLanguageInSubdir: cfg.GetBool("defaultContentLanguageInSubdir"),
DefaultContentLanguage: defaultContentLanguage,
Language: language,
Languages: languages,
Language: language,
Languages: languages,
MultihostTargetBasePaths: multihostTargetBasePaths,
PaginatePath: cfg.GetString("paginatePath"),
}