diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-04-25 13:28:42 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-04-25 14:35:49 +0200 |
commit | babcb339a848842705c1418b2895ab31f7ddb735 (patch) | |
tree | 24d5922b26489954866d03875d8de0effd21963e | |
parent | 7203a95a6069b09a7546e5b2e286abe6455df83a (diff) | |
download | hugo-babcb339a848842705c1418b2895ab31f7ddb735.tar.gz hugo-babcb339a848842705c1418b2895ab31f7ddb735.zip |
config: Setups with only one active language can never be multihost
Fixes #12288
-rw-r--r-- | config/allconfig/configlanguage.go | 3 | ||||
-rw-r--r-- | hugolib/hugo_sites_multihost_test.go | 28 |
2 files changed, 31 insertions, 0 deletions
diff --git a/config/allconfig/configlanguage.go b/config/allconfig/configlanguage.go index 900db75ce..c7f1c276a 100644 --- a/config/allconfig/configlanguage.go +++ b/config/allconfig/configlanguage.go @@ -71,6 +71,9 @@ func (c ConfigLanguage) Environment() string { } func (c ConfigLanguage) IsMultihost() bool { + if len(c.m.Languages)-len(c.config.C.DisabledLanguages) <= 1 { + return false + } return c.m.IsMultihost } diff --git a/hugolib/hugo_sites_multihost_test.go b/hugolib/hugo_sites_multihost_test.go index 937166146..004da351d 100644 --- a/hugolib/hugo_sites_multihost_test.go +++ b/hugolib/hugo_sites_multihost_test.go @@ -252,3 +252,31 @@ Files: {{ range $files }}{{ .Permalink }}|{{ end }}$ b.AssertFileContent("public/en/enpages/mybundle-en/file2.txt", "File 2 en.") b.AssertFileContent("public/fr/section/mybundle/file2.txt", "File 2 en.") } + +func TestMultihostAllButOneLanguageDisabledIssue12288(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +defaultContentLanguage = "en" +disableLanguages = ["fr"] +#baseURL = "https://example.com" +[languages] +[languages.en] +baseURL = "https://example.en" +weight = 1 +[languages.fr] +baseURL = "https://example.fr" +weight = 2 +-- assets/css/main.css -- +body { color: red; } +-- layouts/index.html -- +{{ $css := resources.Get "css/main.css" | minify }} +CSS: {{ $css.Permalink }}|{{ $css.RelPermalink }}| +` + + b := Test(t, files) + + b.AssertFileContent("public/css/main.min.css", "body{color:red}") + b.AssertFileContent("public/index.html", "CSS: https://example.en/css/main.min.css|/css/main.min.css|") +} |