Could anyone with more insight let me know why this code is failing? Removing the $attr
part of the code makes the error disappear.
parse failed: template: _default/test.html:11: undefined variable "$heading"
{{ define "main" }}
{{- $heading := .Params.heading -}}
{{- $attr := "data-pagefind-body" -}}
{{- $attr := printf $attr | safeHTMLAttr }}
{{- end -}}
<h1 class="{{- if $heading }} {{- else }} {{- end }}">{{ .Title }}</h1>
{{- end -}}
The heading
front matter value appears in the pages (.Kind "page"
) of a multipage post.