Skip to content

Commit

Permalink
hugolib: Do not fall back to site title if not set in content file
Browse files Browse the repository at this point in the history
See #5784
  • Loading branch information
bep committed Mar 26, 2019
1 parent 10bb614 commit 9bc6187
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hugolib/page__meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions hugolib/page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
---
Expand Down

0 comments on commit 9bc6187

Please sign in to comment.