Hugo Markdown Rendering - Hyperlink Newtab
Since I’m in a hurry let’s get straight to it, so I just recently started blogging again after so long, but this time the framework I’m using on my blog website is Hugo , in short it’s a markdown framework product that can be used by many people easily, for the setup maybe next I will post specifically from the scratch…
Okay so the problem when blogging on this framework is one of them when creating hyperlink syntax when rendered it can’t open in newtab, Alhamdulillah after I searched the solution is by adding some scripts that can be auto-rendered by hugo, let’s check it out..!
Create render-link.html file
$ cd layouts/_default/
$ mkdir _markup && vi _markup/render-link.html
Enter the following html code.. into the vi screen
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank"{{ end }}>{{ .Text }}</a>
Done. Just push your repo again.. that’s it.
source : https://gohugo.io/getting-started/configuration-markup#markdown-render-hooks
Hope this helps.. :)