baker
1
& in link text rendering to &
on screen
[Laurel & Hardy](/laurel-hardy/)
renders to Laurel & Hardy
Same for:
[Laurel & Hardy](/laurel-hardy/)
[Laurel & Hardy](/laurel-hardy/)
[Laurel & Hardy](/laurel-hardy/)
I am on windows with Hugo 0.99.0
single.html uses > {{ .Content | absLangURL }}
Is there any Hugo way to get the & in a link text? Yes, I am aware that I can write [Laurel and Hardy]
()
Hugo 0.99.1/Win10/WSL1/Debian
That’s true and expected in HTML.
<a href="/laurel-hardy/">Laurel & Hardy</a>
But on my page I see:

EDIT: That looks a bit weird for me to let run the whole content through a absLangURL
pipe
{{ .Content | absLangURL }}
But doesn’t change the result in my case.
1 Like
I suspect that you created a markdown render hook for links, but neglected to pass .Text
through the safeHTML
function.
1 Like
baker
4
Thank you. That pointed my to the culprit, the render links code:
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}" {{ end }} {{ if strings.HasPrefix .Destination "http" }} target="_blank"{{ end }}>{{ .Text }}</a>
Added safetHTM
L :
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}" {{ end }} {{ if strings.HasPrefix .Destination "http" }} target="_blank"{{ end }}>{{ .Text | safeHTML }}</a>
@ GhsvsDe
This renders correctly:
<a href="/laurel-hardy/">Laurel & Hardy</a>
>> Laurel & Hardy
Wasn’t on my list, but good to know.
system
Closed
5
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.