Got error when using .Site.Pages in partial template? [Solved]


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?



1 Like

Hello @yingzhox, 欢迎! :slight_smile:

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! :slight_smile:

(Note to self: We should probably add a note about that “dot”, which is almost always needed, to the documentation at

P.S. Oops, I waited too long before I actually send it. Glad that you found the answer yourself though! :slight_smile:

1 Like