Repository: gohugoio/hugo (language: go)

Issue:
.RegularPagesRecursive is not recursive on home page
`.RegularPagesRecursive` works as expected on section pages, but not on the home page. All you get are the regular pages adjacent to content/_index.md.

We can either document the behavior or change it. I'm fine either way.


Discussion / hints:

Fix patch:
diff --git a/hugolib/page.go b/hugolib/page.go
index 81ba68aa42a..718326d7b94 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -254,7 +254,7 @@ func (p *pageState) RegularPagesRecursive() page.Pages {
 	p.regularPagesRecursiveInit.Do(func() {
 		var pages page.Pages
 		switch p.Kind() {
-		case kinds.KindSection:
+		case kinds.KindSection, kinds.KindHome:
 			pages = p.getPagesRecursive()
 		default:
 			pages = p.RegularPages()


Test patch:
diff --git a/hugolib/pagecollections_test.go b/hugolib/pagecollections_test.go
index 1be2962621c..b11fc9899ad 100644
--- a/hugolib/pagecollections_test.go
+++ b/hugolib/pagecollections_test.go
@@ -432,3 +432,22 @@ Sect1 RegularPagesRecursive: page:/docs/sect1/ps1/|page:/docs/sect1/ps2/|page:/d
 
 `)
 }
+
+func TestRegularPagesRecursiveHome(t *testing.T) {
+	files := `
+-- hugo.toml --
+-- content/p1.md --
+-- content/post/p2.md --
+-- layouts/index.html --
+RegularPagesRecursive: {{ range .RegularPagesRecursive }}{{ .Kind }}:{{ .RelPermalink}}|{{ end }}|End.
+`
+
+	b := NewIntegrationTestBuilder(
+		IntegrationTestConfig{
+			T:           t,
+			TxtarString: files,
+		}).Build()
+
+	b.AssertFileContent("public/index.html", `RegularPagesRecursive: page:/p1/|page:/post/p2/||End.`)
+
+}