hugolib: Do not render aliases if the page is not rendered

Closes #14807
This commit is contained in:
Joe Mooring
2026-04-25 06:41:38 -07:00
committed by Bjørn Erik Pedersen
parent 633cc772e0
commit 8920d56e95
4 changed files with 43 additions and 3 deletions
+40
View File
@@ -749,3 +749,43 @@ Output format: foo|Title: {{ .Title }}
</head>
`)
}
// Issue 14807
func TestDoNotRenderAliasesIfPageNotRendered14807(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
-- content/p1.md --
---
title: p1
aliases: [p1-alias]
---
-- content/p2.md --
---
title: p2
aliases: [p2-alias]
build:
render: never
---
-- content/p3.md --
---
title: p3
aliases: [p3-alias]
build:
render: link
---
-- layouts/page.html --
{{ .Title }}
`
b := Test(t, files)
b.AssertFileExists("public/p1/index.html", true)
b.AssertFileExists("public/p2/index.html", false)
b.AssertFileExists("public/p3/index.html", false)
b.AssertFileExists("public/p1-alias/index.html", true)
b.AssertFileExists("public/p2-alias/index.html", false)
b.AssertFileExists("public/p3-alias/index.html", false)
}
+1 -1
View File
@@ -191,7 +191,7 @@ DATA
files := filesForDisabledKind("")
b := Test(t, files)
b.AssertFileExists("public/sect/no-render-link/index.html", false)
b.AssertFileContent("public/link-alias/index.html", "refresh")
b.AssertFileExists("public/link-alias/index.html", false)
})
t.Run("Build config, no publish resources", func(t *testing.T) {
+1 -1
View File
@@ -86,7 +86,7 @@ func newPageOutput(
type pageOutput struct {
p *pageState
// Set if this page isn't configured to be rendered to this format.
// Set if this page is configured to be rendered to this format.
render bool
f output.Format
+1 -1
View File
@@ -154,7 +154,7 @@ func pageRenderer(
}
}
if !s.conf.DisableAliases && !s.h.BuildState.IsRebuild() {
if !s.conf.DisableAliases && !s.h.BuildState.IsRebuild() && p.render {
of := p.outputFormat()
if of.IsHTML && of.Permalinkable {
// Render any aliases for this page.