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>

gohugo.io/getting-started/configuration-markup#link-with-title-markdown-example


:face_with_raised_eyebrow: It’s a little weird, this doesn’t work on the home page awesome-program-files.vercel.app ; but the other document pages work awesome-program-files.vercel.app/docs/example/table-of-contents . 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 transform.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/

layouts/shortcodes/columns.html

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

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