Let’s say you are using the same partial for the header of the posts in both section page (/blog/) and single page (/blog/hello-world/):

{{ partial "partial-blog-single-header.html" . }}

Hugo doesn’t have {{ if .IsSinglePage }} so it’s not such a trivial task to detect single post pages.

You can solve this using the Scratch — a container for temporary local variables.

In your single post template, set the variable single to true and call the partial:

{{ $.Scratch.Add "single" true }}
{{ partial "partial-blog-single-header.html" . }}

Many templates can be using this partial, but only this particular partial call which has Scratch.add above its line will see the variable.

Now, inside the partial, test if the variable is set. If it is, the partial is called from a single page template. If it’s not set, partial is called from another template (in my case, listing template).

Here’s how I’m setting the titles to be linked only on non-single pages:

{{ if $.Scratch.Get "single" }}
  <h1 itemprop="headline">{{ .Title }}</h1>
{{ else }}
  <a href="{{ .Permalink }}"><h1 itemprop="headline">{{ .Title }}</h1></a>
{{ end }}

Also, this might be useful when loading the comments on the single pages only.