Last active
January 24, 2024 22:01
-
-
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 >}}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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> |
Can you use this in page templates like single.html
instead of in markdown? If I want all pages to use the same google font?
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
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
This shows the end result ...
Font - some examples you can try
{{< typography font="monoton" size="30px" style="italic" weight="bold" >}}
You are awesome.
You're even better!
What else ...
{{< /typography >}}
{{< typography font="Roboto" size="30px" weight="lighter" >}}
You are awesome.
You're even better!
What else ...
{{< /typography >}}