A few small tricks not really worth having their own page:
Expand on click (yes you need to click here)
You can do that simply and JS free with that structure:
<details>
<summary>Some Header</summary>
<div>Some hidden text</div>
</details>
The classic Youtube shortcode:
{{< youtube w7Ft2ymGmfc >}}
Open external link in a new tab. Typically you want external links to open in a new tab. Very easy!
- Create
layouts/_default/_markup/render-link.html
- Add this line:
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank"{{ end }}>{{ .Text | markdownify }}</a>
That’s all! Or nearly all. That shortcode works up to about Hugo 0.96 (March 2022), later version (tested with 0.97.3 ext) throw an error due to markdownify
, so simply remove the | markdownify
and you are fine again.
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank"{{ end }}>{{ .Text }}</a>
External links will open in a new tab > Source + Credit - and local links will open in the same tab > broetchen