Skip to content

Commit

Permalink
Fix handling of build options for term pages
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Feb 18, 2024
1 parent 60b176c commit f21f8fd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hugolib/content_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (f ContentFactory) CreateContentPlaceHolder(filename string, force bool) (s
title: "Content Placeholder"
_build:
render: never
list: never
list: local
publishResources: false
---
Expand Down
8 changes: 8 additions & 0 deletions hugolib/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,14 @@ func (s *Site) shouldBuild(p page.Page) bool {
if !s.conf.IsKindEnabled(p.Kind()) {
return false
}
switch p.Kind() {
case kinds.KindTerm:
if ps, ok := p.(*pageState); ok {
if ps.m.noLink() && !ps.m.shouldListAny() {
return false
}
}
}
return shouldBuild(s.Conf.BuildFuture(), s.Conf.BuildExpired(),
s.Conf.BuildDrafts(), p.Draft(), p.PublishDate(), p.ExpiryDate())
}
Expand Down
27 changes: 27 additions & 0 deletions hugolib/taxonomy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,3 +858,30 @@ draft: true

b.AssertFileExists("public/tags/a/index.html", false)
}

func TestTermBuildNeverRenderNorList(t *testing.T) {
t.Parallel()

files := `
-- layouts/index.html --
|{{ len site.Taxonomies.tags }}|
-- content/p1.md --
---
title: p1
tags: [a]
---
-- content/tags/a/_index.md --
---
title: tag-a-title-override
build:
render: never
list: never
---
`

b := Test(t, files)

b.AssertFileExists("public/tags/a/index.html", false)
b.AssertFileContent("public/index.html", "|0|")
}

0 comments on commit f21f8fd

Please sign in to comment.