aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-08-15 18:25:21 +0200
committerBjørn Erik Pedersen <[email protected]>2019-08-15 20:41:48 +0200
commit6ccf50ea7bb291bcbe1d56a4d697a6fd57a9c629 (patch)
treeff3d3d6c8c82593b452a518e32f47760b2524fd3
parent67524c993623871626f0f22e6a2ac705a816a959 (diff)
downloadhugo-6ccf50ea7bb291bcbe1d56a4d697a6fd57a9c629.tar.gz
hugo-6ccf50ea7bb291bcbe1d56a4d697a6fd57a9c629.zip
hugolib: Fix draft etc. handling of _index.md pages
We will need to revisit this with a proper spec, but this commit makes sure that draft/expiryDate etc. set in front matter on _index.md content files that should disable the page will: * Not crash * Make the rendered page not render any `.Content`. Fixes #6222 Fixes #6210
-rw-r--r--hugolib/page__per_output.go4
-rw-r--r--hugolib/taxonomy_test.go30
2 files changed, 34 insertions, 0 deletions
diff --git a/hugolib/page__per_output.go b/hugolib/page__per_output.go
index 70bb3b223..3638f9669 100644
--- a/hugolib/page__per_output.go
+++ b/hugolib/page__per_output.go
@@ -67,6 +67,10 @@ func newPageContentOutput(p *pageState) func(f output.Format) (*pageContentOutpu
}
initContent := func() (err error) {
+ if p.cmap == nil {
+ // Nothing to do.
+ return nil
+ }
defer func() {
// See https://github.com/gohugoio/hugo/issues/6210
if r := recover(); r != nil {
diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go
index 294e4f1a0..e159f8c13 100644
--- a/hugolib/taxonomy_test.go
+++ b/hugolib/taxonomy_test.go
@@ -352,3 +352,33 @@ categories: ["regular"]
b.Assert(dra, qt.IsNil)
}
+
+// See https://github.com/gohugoio/hugo/issues/6222
+// We need to revisit this once we figure out what to do with the
+// draft etc _index pages, but for now we need to avoid the crash.
+func TestTaxonomiesIndexDraft(t *testing.T) {
+ t.Parallel()
+
+ b := newTestSitesBuilder(t)
+ b.WithContent(
+ "categories/_index.md", `---
+title: "The Categories"
+draft: true
+---
+
+This is the invisible content.
+
+`)
+
+ b.WithTemplates("index.html", `
+{{ range .Site.Pages }}
+{{ .RelPermalink }}|{{ .Title }}|{{ .WordCount }}|{{ .Content }}|
+{{ end }}
+`)
+
+ b.Build(BuildCfg{})
+
+ // We publish the index page, but the content will be empty.
+ b.AssertFileContent("public/index.html", " /categories/|The Categories|0||")
+
+}