Skip to content

Commit

Permalink
Fix panic when home page is drafted
Browse files Browse the repository at this point in the history
Fixes #6927
  • Loading branch information
bep committed Feb 22, 2020
1 parent ca68abf commit 0bd6356
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hugolib/content_map_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,12 @@ func (m *pageMaps) AssemblePages() error {
return err
}

if pm.s.home == nil {
// Home is disabled, everything is.
pm.bundleTrees.DeletePrefix("")
return nil
}

if err := pm.assembleTaxonomies(); err != nil {
return err
}
Expand Down
44 changes: 44 additions & 0 deletions hugolib/taxonomy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,50 @@ Content.

}

// https://github.com/gohugoio/hugo/issues/6927
func TestTaxonomiesHomeDraft(t *testing.T) {
t.Parallel()

b := newTestSitesBuilder(t)
b.WithContent(
"_index.md", `---
title: "Home"
draft: true
---
Content.
`,
"posts/_index.md", `---
title: "Posts"
draft: true
---
Content.
`,
"posts/page.md", `---
title: "The Page"
categories: ["cool"]
---
Content.
`,
)

b.WithTemplates("index.html", `
NO HOME FOR YOU
`)

b.Build(BuildCfg{})

b.Assert(b.CheckExists("public/index.html"), qt.Equals, false)
b.Assert(b.CheckExists("public/categories/index.html"), qt.Equals, false)
b.Assert(b.CheckExists("public/posts/index.html"), qt.Equals, false)

}

// https://github.com/gohugoio/hugo/issues/6173
func TestTaxonomiesWithBundledResources(t *testing.T) {
b := newTestSitesBuilder(t)
Expand Down

0 comments on commit 0bd6356

Please sign in to comment.