Hi,
I have a post under /content/post, when I use:
{{ range first 10 .Site.Pages }}
{{ end }}
In my partial page, I get:
ERROR: 2015/03/05 reflect: call of reflect.Value.Type on zero Value in partials/sidebar.html
What should I do ?
And what’s difference between partial and .Render?
Thanks!
Hello @yingzhox, 欢迎!
Please check in layouts/
and see which file you have included this partial. The problem lies not in partials/sidebar.html itself, but rather in the way it was called. If you have something like this:
{{ partial "sidebar.html" }}
You are missing “the dot”, which means that no context is passed onto partials/sidebar.html
, hence .Site.Pages
refers to nothing. The fix is simple:
{{ partial "sidebar.html" . }}
Please try it and see if it works!
(Note to self: We should probably add a note about that “dot”, which is almost always needed, to the documentation at http://gohugo.io/templates/partials/.)
P.S. Oops, I waited too long before I actually send it. Glad that you found the answer yourself though!
1 Like