diff --git a/hugolib/config_test.go b/hugolib/config_test.go index 4af9b7998c4..2f9c6e3f678 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -1002,3 +1002,41 @@ Home conf := b.H.Configs.Base b.Assert(conf.IsKindEnabled("term"), qt.Equals, false) } + +// Issue #11000 +func TestConfigEmptyTOMLString(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +[mediaTypes] +[mediaTypes."text/htaccess"] +suffixes = ["htaccess"] +[outputFormats] +[outputFormats.htaccess] +mediaType = "text/htaccess" +baseName = "" +isPlainText = false +notAlternative = true +-- content/_index.md -- +--- +outputs: ["html", "htaccess"] +--- +-- layouts/index.html -- +HTML. +-- layouts/_default/list.htaccess -- +HTACCESS. + + + +` + b := NewIntegrationTestBuilder( + IntegrationTestConfig{ + T: t, + TxtarString: files, + }, + ).Build() + + b.AssertFileContent("public/.htaccess", "HTACCESS") + +} diff --git a/output/config.go b/output/config.go index 7b83ef9de94..86e5bcfaaf3 100644 --- a/output/config.go +++ b/output/config.go @@ -32,6 +32,11 @@ type OutputFormatConfig struct { Format } +var defaultOutputFormat = Format{ + BaseName: "index", + Rel: "alternate", +} + func DecodeConfig(mediaTypes media.Types, in any) (*config.ConfigNamespace[map[string]OutputFormatConfig, Formats], error) { buildConfig := func(in any) (Formats, any, error) { f := make(Formats, len(DefaultFormats)) @@ -59,20 +64,12 @@ func DecodeConfig(mediaTypes media.Types, in any) (*config.ConfigNamespace[map[s continue } - var newOutFormat Format + newOutFormat := defaultOutputFormat newOutFormat.Name = k if err := decode(mediaTypes, v, &newOutFormat); err != nil { return f, nil, err } - // We need values for these - if newOutFormat.BaseName == "" { - newOutFormat.BaseName = "index" - } - if newOutFormat.Rel == "" { - newOutFormat.Rel = "alternate" - } - f = append(f, newOutFormat) }