Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Johnson <me@carlmjohnson.net>2020-03-20 16:35:41 +0300
committerGitHub <noreply@github.com>2020-03-20 16:35:41 +0300
commit95f492114e33fc6e4d9dcfd2b7c1eca5c50d755f (patch)
tree1bcbfdd901a99eb712740d262128deb87ff6b31f /hugolib
parentc947351d7c4273b24663a56d8f32c8c011e9841f (diff)
Fix GetTerms nil pointer
Fixes #7061
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/page.go2
-rw-r--r--hugolib/taxonomy_test.go6
2 files changed, 5 insertions, 3 deletions
diff --git a/hugolib/page.go b/hugolib/page.go
index 16c320ecd..f71c4d9b8 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -141,7 +141,7 @@ func (p *pageState) GetTerms(taxonomy string) page.Pages {
if p.IsHome() {
// TODO(bep) make this less magical, see taxonomyEntries.Insert.
self = "/" + page.KindHome
- } else {
+ } else if p.treeRef != nil {
self = p.treeRef.key
}
diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go
index f8dca6a1f..f37e37b89 100644
--- a/hugolib/taxonomy_test.go
+++ b/hugolib/taxonomy_test.go
@@ -625,7 +625,9 @@ Category Paginator {{ range $categories.Paginator.Pages }}{{ .RelPermalink }}|{{
Cats Paginator {{ range $cats.Paginator.Pages }}{{ .RelPermalink }}|{{ end }}:END
`)
-
+ b.WithTemplatesAdded("404.html", `
+404 Terms: {{ range .GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END
+ `)
b.Build(BuildCfg{})
cat := b.GetPage("categories")
@@ -647,7 +649,7 @@ Home Terms: /categories/dogs/|/categories/gorillas/|:END
Cats Paginator /section/p1/|/section/|:END
Category Paginator /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END
`)
-
+ b.AssertFileContent("public/404.html", "\n404 Terms: :END\n\t")
b.AssertFileContent("public/categories/funny/index.xml", `<link>http://example.com/section/p1/</link>`)
b.AssertFileContent("public/categories/index.xml", `<link>http://example.com/categories/funny/</link>`)