diff --git a/hugolib/page__meta.go b/hugolib/page__meta.go index 2c6b0a85d..9f5f369b3 100644 --- a/hugolib/page__meta.go +++ b/hugolib/page__meta.go @@ -545,7 +545,7 @@ func (p *pageMeta) applyDefaultValues() error { } } - if p.title == "" { + if p.title == "" && p.f.IsZero() { switch p.Kind() { case page.KindHome: p.title = p.s.Info.title diff --git a/hugolib/page_test.go b/hugolib/page_test.go index f243740c6..570d09ac6 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -1175,8 +1175,10 @@ func TestPageWithZeroFile(t *testing.T) { } func TestHomePageWithNoTitle(t *testing.T) { - b := newTestSitesBuilder(t).WithSimpleConfigFile(). - WithTemplatesAdded("index.html", "Title|{{ with .Title }}{{ . }}{{ end }}|") + b := newTestSitesBuilder(t).WithConfigFile("toml", ` +title = "Site Title" +`) + b.WithTemplatesAdded("index.html", "Title|{{ with .Title }}{{ . }}{{ end }}|") b.WithContent("_index.md", `--- description: "No title for you!" ---