I’m trying to share a partial between a single page and a summary view. In the single page I need to use h1 for the title and h2 when the same page is shown in a (summary) list. Therefor I need to distinguish where the page is used. the .Kind and .Type and .IsPage always show the same value.
So how can I distinguish where the page is show/rendered?
Pseudo templates:
header.html
{{ if SOMECOMPARISON }}<h1>{{ else }}<h2>{{ end }}
{{ .Title }}
{{ if SOMECOMPARISON }}</h1>{{ else }}</h2>{{ end }}
That is correct. Within the range, the context (the dot) represents the page within the current range iteration, not the page doing the ranging. You need some context for your context.
You can do this when calling a partial by doing something like this:
However, in addition to partials you are using content views, and .Render does not take any arguments (your pseudo code is incorrect). This issue, specifically this comment, speaks to the limitation.
Option 1
Convert your content view (summary.html) into a partial, and pass additional arguments as shown above.
Thanks for those recommendations. I think that #3 would be the best option for this specific case but I was also asking because I’m using this to learn Hugo.
I have implemented a solution using Scratch for now and will see where that brings me.