I call {{partial "recent.html" .}} in my index.html file and in the partial do {{ range first 5 .Site.Pages }}. That works fine. Then I noticed that I had a similar partial that calls {{ range first 5 .Data.Pages }}. That got me to wondering what the difference is between them is on the index.html file. I know that .Data is for the current node. At index.html, doesn’t that node include everything?
I ask because eventually I want to write that partial to take a list of pages and iterate through them rather than the . and using .Site.Pages. This is for both list and single templates.
I’ll just chime in and say that I agree with you. The .Data element confuses me, too. I thought it was related to the Data Files features, but I’ve seen it used in other ways. I’m looking forward to this discussion.
.Site.Pages = All the Pages (note the capital P) in the site.
.Data.Pages: All the Pages for the given Node (sections, taxonomies). This will be a subset of the above for all other nodes than the home page: On that Node I believe these slices are the same.
@moorereason As a new user, I agree that it’s confusing. Why not .Node.Pages (since the distinction between a node might already be a bit confusing for developers coming from other SSGs and intuitive naming will serve to reinforce the concept) and reserve .Data for the current $.Site.Data files?