Skip to content

Instantly share code, notes, and snippets.

@damien1
Last active January 24, 2024 22:01
Show Gist options
  • Save damien1/8fd26c6fc0dc864ab2058487f2702c41 to your computer and use it in GitHub Desktop.
Save damien1/8fd26c6fc0dc864ab2058487f2702c41 to your computer and use it in GitHub Desktop.
Hugo Shortcode add Google Fonts and style to selected text. Visit my site for details https://bit.ly/31PSv6d example: {{< typography font="monoton" size="100px" style="italic" >}}You are awesome. You're even better! {{< /typography >}}
<!-- for usage details visit https://bit.ly/31PSv6d -->
{{ $font := .Get "font" }}
{{ $size := .Get "size" }}
{{ $style := .Get "style" | default "normal" }}
{{ $weight := .Get "weight" | default "normal" }}
<link href="https://fonts.googleapis.com/css?family={{ $font }}" rel="stylesheet" type="text/css">
<div style="font-family:'{{ $font }}'; font-size:{{ $size }}; font-style:{{ $style}}; font-weight:{{ $weight }}">
{{- .Inner -}}
</div>
@pwinston
Copy link

Thank you, that makes sense. I'm still very new to Hugo. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment