May be you just need to change $1 (and so on) to ${1}? I know for fact that this works ![]()
(because it looks like you are doing something similar Looks like you are doing something else … not sure why you are inserting the id, because Hugo/Blackfriday is already doing that for you)
Snippet from above link:
{{ $content = $content | replaceRE "(<h[2-9] id=\"([^\"]+)\".+)(</h[2-9]+>)" `${1} <a class="headline-