summaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2020-10-14 11:23:24 +0200
committerBjørn Erik Pedersen <[email protected]>2020-10-14 16:59:37 +0200
commitead5799f7ea837fb2ca1879a6d37ba364e53827f (patch)
tree9f7b753877413ace8a86b2c86a256651361273c3 /hugolib
parentd57be113243be4b76310d4476fbb7525d1452658 (diff)
downloadhugo-ead5799f7ea837fb2ca1879a6d37ba364e53827f.tar.gz
hugo-ead5799f7ea837fb2ca1879a6d37ba364e53827f.zip
Render aliases even if render=link
Fixes #7832
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/content_map.go14
-rw-r--r--hugolib/disableKinds_test.go7
-rw-r--r--hugolib/page__paths.go2
-rw-r--r--hugolib/site_render.go14
4 files changed, 32 insertions, 5 deletions
diff --git a/hugolib/content_map.go b/hugolib/content_map.go
index 33ef4f8dd..652609e26 100644
--- a/hugolib/content_map.go
+++ b/hugolib/content_map.go
@@ -830,6 +830,13 @@ var (
}
return n.p.m.noRender()
}
+
+ contentTreeNoLinkFilter = func(s string, n *contentNode) bool {
+ if n.p == nil {
+ return true
+ }
+ return n.p.m.noLink()
+ }
)
func (c *contentTree) WalkQuery(query pageMapQuery, walkFn contentTreeNodeCallback) {
@@ -865,6 +872,13 @@ func (c contentTrees) WalkRenderable(fn contentTreeNodeCallback) {
}
}
+func (c contentTrees) WalkLinkable(fn contentTreeNodeCallback) {
+ query := pageMapQuery{Filter: contentTreeNoLinkFilter}
+ for _, tree := range c {
+ tree.WalkQuery(query, fn)
+ }
+}
+
func (c contentTrees) Walk(fn contentTreeNodeCallback) {
for _, tree := range c {
tree.Walk(func(s string, v interface{}) bool {
diff --git a/hugolib/disableKinds_test.go b/hugolib/disableKinds_test.go
index 381442d69..73786c730 100644
--- a/hugolib/disableKinds_test.go
+++ b/hugolib/disableKinds_test.go
@@ -58,6 +58,7 @@ _build:
"sect/no-render-link.md", `
---
title: No Render Link
+aliases: ["/link-alias"]
_build:
render: link
---
@@ -319,10 +320,14 @@ title: Headless Local Lists Sub
p := getPage(b, ref)
b.Assert(p, qt.Not(qt.IsNil))
b.Assert(p.RelPermalink(), qt.Equals, "/blog/sect/no-render-link/")
- b.Assert(p.OutputFormats(), qt.HasLen, 0)
+ b.Assert(p.OutputFormats(), qt.HasLen, 1)
b.Assert(getPageInSitePages(b, ref), qt.Not(qt.IsNil))
sect := getPage(b, "/sect")
b.Assert(getPageInPagePages(sect, ref), qt.Not(qt.IsNil))
+
+ // https://github.com/gohugoio/hugo/issues/7832
+ // It should still render any aliases.
+ b.AssertFileContent("public/link-alias/index.html", "refresh")
})
c.Run("Build config, no publish resources", func(c *qt.C) {
diff --git a/hugolib/page__paths.go b/hugolib/page__paths.go
index 535c60ba0..d41b7c2bc 100644
--- a/hugolib/page__paths.go
+++ b/hugolib/page__paths.go
@@ -76,7 +76,7 @@ func newPagePaths(
}
var out page.OutputFormats
- if !pm.noRender() {
+ if !pm.noLink() {
out = pageOutputFormats
}
diff --git a/hugolib/site_render.go b/hugolib/site_render.go
index d9d60c2fa..7f5bcfb1a 100644
--- a/hugolib/site_render.go
+++ b/hugolib/site_render.go
@@ -323,20 +323,28 @@ func (s *Site) renderRobotsTXT() error {
// renderAliases renders shell pages that simply have a redirect in the header.
func (s *Site) renderAliases() error {
var err error
- s.pageMap.pageTrees.WalkRenderable(func(ss string, n *contentNode) bool {
+ s.pageMap.pageTrees.WalkLinkable(func(ss string, n *contentNode) bool {
p := n.p
if len(p.Aliases()) == 0 {
return false
}
+ pathSeen := make(map[string]bool)
+
for _, of := range p.OutputFormats() {
if !of.Format.IsHTML {
- return false
+ continue
}
- plink := of.Permalink()
f := of.Format
+ if pathSeen[f.Path] {
+ continue
+ }
+ pathSeen[f.Path] = true
+
+ plink := of.Permalink()
+
for _, a := range p.Aliases() {
isRelative := !strings.HasPrefix(a, "/")