Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cascade to self not working for regular pages #14627

@jmooring

Description

@jmooring

Prior to v0.153.0, in the front matter of a regular page, you could cascade a value to that page. Think of this as "cascade to self".

With v0.153.0 and later, "cascade to self" is not possible with regular pages. It still works with section pages, but not with regular pages.

Why would you want to "cascade to self" instead of just placing the values in front matter? So that you can target to a particular environment, e.g.,

---
title: p2
cascade:
  target:
    environment: pubweb
  build:
    list: never
    render: never
    publishResources: false
---

With the example above, that means that the site owner is now publishing pages that were intentionally hidden when building for the "pubweb" environment.

integration test
// Issue 14627
func TestRegularPageCascadeToSelf(t *testing.T) {
	t.Parallel()

	files := `
-- hugo.toml --
disableKinds = ['home','rss','sitemap','taxonomy','term']
environment = 'pubweb'
-- content/s1/_index.md --
---
title: s1
cascade:
  target:
    environment: pubweb
  build:
    list: never
    render: never
    publishResources: false
---
-- content/s1/p1.md --
---
title: p1
---
-- content/s2/_index.md --
---
title: s2
---
-- content/s2/p2.md --
---
title: p2
cascade:
  target:
    environment: pubweb
  build:
    list: never
    render: never
    publishResources: false
---
-- layouts/all.html --
{{ .Title }}|
`

	b := hugolib.Test(t, files)

	b.AssertFileExists("public/s1/index.html", false)
	b.AssertFileExists("public/s1/p1/index.html", false)
	b.AssertFileExists("public/s2/index.html", true)
	b.AssertFileExists("public/s2/p2/index.html", false) // fails
}

Reference: https://discourse.gohugo.io/t/56859

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions