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>
@damien1
Copy link
Author

damien1 commented May 13, 2021

Can you use this in page templates like single.html instead of in markdown?

As this is a shortcode, it's specific for using with markdown ... what you need to do is check your .CSS files and there you can change your fonts - the Google Font website will even provide the necessary code to go in your files

@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