HUGO

replaceRE on render hook

I’m trying render hooks to fix markdown links that end in .md and should end in .html but I am getting a syntax error that I can’t figure out:

<a href="{{ .Destination | replaceRE '\.md$' '\.html' | safeURL }}"
{{ with .Title}} title="{{ . }}" {{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank" rel="noopener" {{ end }}>{{ .Text | safeHTML }}</a>

Am I missing something here? Or maybe there is a better way to achieve the same result ?

Use backticks instead of single quotes.

https://golang.org/ref/spec#Rune_literals
https://golang.org/ref/spec#String_literals

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.