I am trying to link keywords found in .Content with a link tag. When I used the replace function like below, the html tags are showing up as <p>hello</p> instead of rendering them.
{{ range $topics }}
{{- if and (strings.Contains $.Content .) -}}
{{ replace $.Content . "<a href='$Permalink'>.</a>" }}
{{ end }}
{{ end }}
The above code makes $.Content an unrendered string. That is, instead of rendering the html content (which comes from markdown content files), it shows the actual tags like <h2><p> etc.
I have tried applying safeHTML like below, but it doesnt affect the output.
{{ $.Content | safeHTML }}
Is there a way to convert unrendered content to rendered content.
@bep have a question on the replace function. The current replace function replaces all occurrences of the search text. But is there a method that replaces only the first occurrence or a particular index of the occurrence. Sorry I did try looking into the documentation first, but I couldn’t find it.