-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GetTerms: runtime error: invalid memory address or nil pointer dereference #7061
Comments
I tried to create a failing test for this, but failed ... So there must be something I don't understand. |
Hmm, it definitely happens on my site, but I am having trouble reproducing it as a Hugo test. Maybe it's because I'm using non-standard taxonomies? |
If you checkout spotlightpa/poor-richard@f89ff87#diff-5725f8ca9fd37c1438a052e56a003075 and change
to
You get:
|
I think I've figured out how to reproduce it. The |
diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go
index f8dca6a1..52ad6a48 100644
--- a/hugolib/taxonomy_test.go
+++ b/hugolib/taxonomy_test.go
@@ -320,7 +320,7 @@ categories: ["This is Cool", "And new" ]
---
Content.
-
+
`)
}
@@ -535,7 +535,7 @@ Funny:|/p2/|`)
func TestTaxonomiesListPages(t *testing.T) {
b := newTestSitesBuilder(t)
b.WithTemplates("_default/list.html", `
-
+
{{ template "print-taxo" "categories.cats" }}
{{ template "print-taxo" "categories.funny" }}
@@ -570,7 +570,7 @@ categories: ["cats"]
b.Build(BuildCfg{})
b.AssertFileContent("public/index.html", `
-
+
Len categories.cats: 2
categories.cats:|/blog/|
categories.cats:|/|
@@ -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", "xxx")
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>`)
|
In |
Rename breaks build because of gohugoio/hugo#7061. Need to figure out how to make a proper homepage.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug: If a page doesn't have its taxonomy set, .GetTerms panics.
Workaround (e.g. for topic):
What version of Hugo are you using (
hugo version
)?Hugo Static Site Generator v0.67.1/extended darwin/amd64 BuildDate: unknown
Does this issue reproduce with the latest release?
Yes.
The text was updated successfully, but these errors were encountered: