How to "open Link in a new tab" with hugo book

$ hugo version
hugo v0.84.0-2C4689F7B+extended windows/amd64 BuildDate=2021-06-18T17:14:27Z VendorInfo=gohugoio

This is my Hugo repo , Hugo theme is book.

<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank" rel="noopener"{{ end }}>{{ .Text | safeHTML }}</a>

:face_with_raised_eyebrow: It’s a little weird, this doesn’t work on the home page ; but the other document pages work . How to also work on the homepage?

Hi there,

The difference is that on your homepage, the links are inside a shortcode ( {{< columns >}} ).

Inside the shortcode, markdownify is being used. However, from markdownify | Hugo :

Note : if you need Render Hooks, which markdownify doesn’t currently support, …

Thank you very much for your reply.
I have a general idea of ​​the reason, but I am not sure about the best solution to this problem.

Do you have any great suggestions? :coffee:

mkdir layouts/shortcodes
cp themes/book/layouts/shortcodes/columns.html layouts/shortcodes/


<div class="book-columns flex flex-wrap">
  {{ range split .Inner "<--->" }}
  <div class="flex-even markdown-inner">
    {{ . | $.Page.RenderString }}
  {{ end }}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.