I suppose you set the scratch right before invoking the .Content in the template…
{{ range .Pages }}
{{ .Title }}
{{ .Scratch.Set "list" true }}
{{ .Content }}
{{ end }}
I could be wrong but as Hugo builds its pages concurrently it does not guarantee that this Scratch data will be on the page at the moment you wish it does.
Note that the scratch variable is present if I use the regexp search/replace trick for header links instead of a header render hook by doing something like this in the partial template included in the for loop:
@bep@jmooring Sorry, I’m not clear on whether Discourse emails participants about new comments, so tagging you here since there’s been no reply, just in case it doesn’t email.