{{- $ref := relref . (.Get "ref") }} {{- $path := (index (split (.Get "ref") "#") 0) }} {{- $anchor := (index (split (.Get "ref") "#") 1)}} {{- $page := .Site.GetPage $path -}} {{- $pattern := printf `.*?\n#{2,6} (.+) \{#%s\}.*?` $anchor }} {{- $title := $page.RawContent}} {{- $heading := index (findRE $pattern $title 1) 0 }} {{- $heading = replaceRE $pattern "$1" $heading }} {{- with $page -}} {{- end -}}