We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
This works within a markdown file but if I have the markdown within a shortcode like this...
<div class="inverse__content">
{{ .Inner | markdownify | safeHTML }}
</div>
Then the links within that DIV are not getting the same target _blank added :(
Is there any way around this, Agrim? Thank you :)
Try<div class="inverse__content">
{{ .Inner | $.Page.RenderString | safeHTML }}
</div>
See Markdownify function does not call render-link hook #6650
This was driving me nuts! Wish Hugo would do a better job of informing us of such things. :/
Thanks a bunch Agrim.
Thanks! Works like a charm
Thanks for your comment Darko. Glad that it worked well for you.
Very nice solution, but the one thing this does and I can't seem to fix it, is add a space after the link if there is a character directly behind it.
So with:[Link](https://example.com), hello.
You will get:
Link , hello.
Whereas with:<a target="_blank" href="https://example.com">Link</a>, hello.
You get:
Link, hello.
Not sure what the cause is, because I don't see any spaces outside the link code in the render-link itself..
Not sure if anyone lese is having this issue but I can no longer use relative links for internal blog links. Other than that it works great!
Thanks a million, works great!
I've solved this by adding <base target="_blank"> to the partial head
thank you for explaining this, worked like a charm!
Awesome. Although for a content with special characters htmlUnescape or safeHTML has to be used: {{ .Text | safeHTML }}.
Good tip and it worked in local dev, but I was having issues with getting this working in Production (hosted on Netlify).
It turns out it was because this method is only compatible with Hugo v0.62.0+
To fix this, I needed to set the Hugo version that Netlify uses for my site by adding the following to my Netlify.toml file.
[context.production.environment]
HUGO_VERSION = "0.65.3"
You can set the version to whichever you want (I'm currently using v0.65.3), just make sure it's at least 0.62.0.
Note: If you don't already have a Netlify.toml file, then just create it in the root of your site.
Thank you for your help! I would love to see the TLDR at the top of the post ;)
Just save my day.
Thanks
This work for me. Hugo 0.64.0 Thanks for sharing.
Hey, this is super useful! One thing you might update --
{{ .Text | markdownify }}This would make sure that all characters display properly instead of accidentally converting to HTML name codes (happened with my quotes!). Thanks for the code! :)