Skip to content

Commit babcb33

Browse files
committed
config: Setups with only one active language can never be multihost
Fixes #12288
1 parent 7203a95 commit babcb33

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

config/allconfig/configlanguage.go

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ func (c ConfigLanguage) Environment() string {
7171
}
7272

7373
func (c ConfigLanguage) IsMultihost() bool {
74+
if len(c.m.Languages)-len(c.config.C.DisabledLanguages) <= 1 {
75+
return false
76+
}
7477
return c.m.IsMultihost
7578
}
7679

hugolib/hugo_sites_multihost_test.go

+28
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,31 @@ Files: {{ range $files }}{{ .Permalink }}|{{ end }}$
252252
b.AssertFileContent("public/en/enpages/mybundle-en/file2.txt", "File 2 en.")
253253
b.AssertFileContent("public/fr/section/mybundle/file2.txt", "File 2 en.")
254254
}
255+
256+
func TestMultihostAllButOneLanguageDisabledIssue12288(t *testing.T) {
257+
t.Parallel()
258+
259+
files := `
260+
-- hugo.toml --
261+
defaultContentLanguage = "en"
262+
disableLanguages = ["fr"]
263+
#baseURL = "https://example.com"
264+
[languages]
265+
[languages.en]
266+
baseURL = "https://example.en"
267+
weight = 1
268+
[languages.fr]
269+
baseURL = "https://example.fr"
270+
weight = 2
271+
-- assets/css/main.css --
272+
body { color: red; }
273+
-- layouts/index.html --
274+
{{ $css := resources.Get "css/main.css" | minify }}
275+
CSS: {{ $css.Permalink }}|{{ $css.RelPermalink }}|
276+
`
277+
278+
b := Test(t, files)
279+
280+
b.AssertFileContent("public/css/main.min.css", "body{color:red}")
281+
b.AssertFileContent("public/index.html", "CSS: https://example.en/css/main.min.css|/css/main.min.css|")
282+
}

0 commit comments

Comments
 (0)