Links being changed

My links are being changed when being put into href. My links contain <% that are being changed to %3c%25 . I need them to be placed into the href unaltered, same with tel:23123124124 as an example (I was using tel:203948230) is the best option to just set up a shortcode that adds href=“mylinkhere” and place it in my template?

Thanks!

Jeff

You probably want to look at https://gohugo.io/templates/functions/#strings for safeHTML, safeURL and/or urlize functions.

None of those work. safeURL works for telephone but not for the other link with <% in it. safeHTML doesn’t work because in order for it to work i have to do {{ variable | safeHTML | safeURL }} for me not to get the weird ZgotmplZ link and safeURL then changes it back to %20%c7 type codes. I’m at a loss of what to do besides creating a shortcode workaround for this. Maybe I’m not implementing it at the right stage, I’m not sure.

Thanks!

Jeff

Does anyone have any insight into this? I just need a way to have my links that I set in the frontmatter go into the templates without golang template engine modifying them at all.

safeURL makes it so I can use telephone numbers in the href (or other non http: or https: type links) but it doesn’t work for my links that have <%%>

safeHTML doesn’t work without putting in safeURL at the end because if you put safeHTML for some of them it defaults to putting ZgotmplZ into the link instead because the gotemplate detects something is wrong i guess?

urlize sanitizes everything as well, completely changing everything.

Basically my use case is that these html file will be sent through another workflow that will remove the <%stuffhere%> and replace them anyway but they are required to be there to start off.

If anyone has a solution it would be a great help.

Thanks,

Jeff

Here
http://stackoverflow.com/questions/36382624/how-to-get-rid-of-zgotmplz-from-html-template-in-golang

Which links to https://golang.org/pkg/html/template/#URL

How do I use this string type in Hugo?

Sorry for being a bit persistent with this, I’m just unsure how to implement it into my project and it is very important not to have these links changed as it can cause issues.

Thanks!

I apologise on spamming this board a bit. I found a very messy workaround.

Before I would just have
<a href="{{variable}}"
but now I have it without the <a href= and then use {{variable | prinft "<a href=%q" | safeHTML}}
this then adds the a tag onto it but skips the sanitisation that golang adds into the tags. It is the best that I could manage. Hopefully there is a better way that someone can come by and tell me about but for now this works (I think).