Content views and .IsHome/.IsPage

I started using .Render and content views today to rework my site. On my homepage template, I have the following:

  {{ range .Paginator.Pages }}
    {{ .Render "full_view" }}
  {{ end }}

However, I’ve noticed that the .IsPage and .IsHome page variables are wrong when using .Render. What I see is that .IsPage is always true, and .IsHome is always false. Is this expected? The docs imply that all the page variables are passed:

Hugo will pass the entire page object to the following summary.html view template. (See Page Variables for a complete list.)

And both .IsPage and .IsHome are listed as page variables. Am I missing something?

Possibly related - the docs talk about a render method, but all of the examples actually use .Render. I assume it’s supposed to be .Render since that’s the only thing that works as far as I can tell. Is that doc bug or am I more confused than I think? :slight_smile:

Hmmm, actually if I switch the .Render line inside the paginator to be a partial, the context passed to the partial also doesn’t have .IsHome set to true. Now I’m extra confused; I thought I could use partials to get around this but that also seems broken.

This isn’t broken, but you have to understand what Page you are dealing with.

Thanks @bep - ‘broken’ was the wrong word to use. What’s broken is my understanding. :slight_smile:

With regards to understanding the Page I’m dealing with, is there a section of the docs I should read more carefully? I’m confused about the difference in .IsHome when I call a partial from inside a {{ range .Paginator.Pages }} vs. outside.

It makes sense to me that within the range, the context (.) is different than it is outside the range. But my (very likely wrong) mental model is that these are properties of a Page, and I think I’m seeing a Page within my partial in both cases. But in one that page has IsHome=true, and in the other (when called within the range) has IsHome=false. Are the pages returned by the Paginator different than regular pages?

Ultimately, I’m trying to create a re-usable partial that can be included on any page, and adapt itself based on where it is included. Is there a different approach to solving that problem?

It just occurred to me that if I am using partials, I can pass additional data into the partial and use that to thread the “I’m being rendered in the home page ‘context’” info through to all the relevant partials. I was originally trying to use content views to solve my problem, since they map better to my mental model (content types should manage their own rendering, and templates should simply say what ‘view’ of the content type they want), but if I’m back to partials I have more options. I’ll investigate this some more.