Revert the 0.57 home.Pages change

In 0.57 we change the behaviour of home.Pages to be in line with the other sections. This has created a lot noise and breakage in the wild.

This commit reverts that change, but adds a warning that we will change this in 0.58 and that you should consider using .Site.RegularPages if that is what you want.
This commit is contained in:
Bjørn Erik Pedersen 2019-08-17 12:59:41 +02:00
parent 416493b548
commit ab40ce679f
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
2 changed files with 10 additions and 3 deletions

View file

@ -193,7 +193,7 @@ Some **Markdown** in JSON shortcode.
b.AssertFileContent("public/index.html", b.AssertFileContent("public/index.html",
"home|In English", "home|In English",
"Site params: Rules", "Site params: Rules",
"Pages: Pages(6)|Data Pages: Pages(6)", "Pages: Pages(18)|Data Pages: Pages(18)",
"Paginator: 1", "Paginator: 1",
"First Site: In English", "First Site: In English",
"RelPermalink: /", "RelPermalink: /",

View file

@ -146,7 +146,9 @@ func (p *pageState) RegularPages() page.Pages {
switch p.Kind() { switch p.Kind() {
case page.KindPage: case page.KindPage:
case page.KindSection, page.KindHome, page.KindTaxonomyTerm: case page.KindHome:
pages = p.s.RegularPages()
case page.KindSection, page.KindTaxonomyTerm:
pages = p.getPages() pages = p.getPages()
case page.KindTaxonomy: case page.KindTaxonomy:
all := p.Pages() all := p.Pages()
@ -172,7 +174,12 @@ func (p *pageState) Pages() page.Pages {
switch p.Kind() { switch p.Kind() {
case page.KindPage: case page.KindPage:
case page.KindSection, page.KindHome: case page.KindHome:
// See https://github.com/gohugoio/hugo/issues/6238
// Note: When making the change below, also remember RegularPages.
helpers.DistinctWarnLog.Println(`In the next Hugo version (0.58.0) we will change how $home.Pages behaves. If you want to list all regular pages, replace .Pages or .Data.Pages with .Site.RegularPages in your home page template.`)
pages = p.s.RegularPages()
case page.KindSection:
pages = p.getPagesAndSections() pages = p.getPagesAndSections()
case page.KindTaxonomy: case page.KindTaxonomy:
termInfo := p.bucket termInfo := p.bucket