Only duplicate resource output in multihost mode
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 14 Aug 2018 10:04:17 +0000 (12:04 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 14 Aug 2018 10:04:17 +0000 (12:04 +0200)
Yesterday's commit was a little too agressive.

This commit makes sure that the duplication of resources to public/en etc. is only performed in multihost mode.

See #5058

hugolib/paths/paths.go
hugolib/resource_chain_test.go

index 10acf0cb38b4e9e0b3ac98d71e2bfc105b6bf76b..625d68ec640f5b65ebc016c26dd137fd18f9f9bb 100644 (file)
@@ -139,10 +139,8 @@ func New(fs *hugofs.Fs, cfg config.Provider) (*Paths, error) {
                absResourcesDir = FilePathSeparator
        }
 
-       multilingual := cfg.GetBool("multilingual")
-
        var multihostTargetBasePaths []string
-       if multilingual {
+       if languages.IsMultihost() {
                for _, l := range languages {
                        multihostTargetBasePaths = append(multihostTargetBasePaths, l.Lang)
                }
@@ -167,7 +165,7 @@ func New(fs *hugofs.Fs, cfg config.Provider) (*Paths, error) {
 
                themes: config.GetStringSlicePreserveString(cfg, "theme"),
 
-               multilingual:                   multilingual,
+               multilingual:                   cfg.GetBool("multilingual"),
                defaultContentLanguageInSubdir: cfg.GetBool("defaultContentLanguageInSubdir"),
                DefaultContentLanguage:         defaultContentLanguage,
 
index 0a4c3bd1fe77c310181f5b1763391b0f75cfe612..ad0d9611cb3c7bd4eedafaa8c53f5453d7a2f8ba 100644 (file)
@@ -385,3 +385,20 @@ $color: #333;
                test.verify(b)
        }
 }
+
+func TestMultiSiteResource(t *testing.T) {
+       t.Parallel()
+       assert := require.New(t)
+
+       b := newMultiSiteTestDefaultBuilder(t)
+
+       b.CreateSites().Build(BuildCfg{})
+
+       // This build is multilingual, but not multihost. There should be only one pipes.txt
+       b.AssertFileContent("public/fr/index.html", "French Home Page", "String Resource: /blog/text/pipes.txt")
+       assert.False(b.CheckExists("public/fr/text/pipes.txt"))
+       assert.False(b.CheckExists("public/en/text/pipes.txt"))
+       b.AssertFileContent("public/en/index.html", "Default Home Page", "String Resource: /blog/text/pipes.txt")
+       b.AssertFileContent("public/text/pipes.txt", "Hugo Pipes")
+
+}