Skip to content

Commit

Permalink
Only duplicate resource output in multihost mode
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bep committed Aug 14, 2018
1 parent 78f8475 commit 56c6155
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
6 changes: 2 additions & 4 deletions hugolib/paths/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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,

Expand Down
17 changes: 17 additions & 0 deletions hugolib/resource_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

}

0 comments on commit 56c6155

Please sign in to comment.