Skip to content

Instantly share code, notes, and snippets.

@scivision
Created June 30, 2025 00:03
Show Gist options
  • Save scivision/b35c657140c15766b01e07c0b752a59a to your computer and use it in GitHub Desktop.
Save scivision/b35c657140c15766b01e07c0b752a59a to your computer and use it in GitHub Desktop.
Hugo alert boxes
/* place under assets/css/blockquote.css */
/* General alert styling */
.alert {
padding: 1rem;
margin-bottom: 1rem;
border: 1px solid transparent;
border-radius: .25rem;
}
.alert-title {
display: block;
margin-bottom: 0.5rem;
font-weight: bold;
}
/* Note style */
.alert-note {
color: #1c4b78;
background-color: #d1ecf1;
border-color: #bee5eb;
}
.alert-note .alert-title {
color: #0c5460;
}
/* Warning style */
.alert-warning {
color: #856404;
background-color: #fff3cd;
border-color: #ffeeba;
}
.alert-warning .alert-title {
color: #856404;
}
# add to hugo.yaml
markup:
goldmark:
parser:
attribute:
block: true
title: true
<!-- place at layouts/_default/_markup/render-blockquote.html -->
{{ resources.Get "css/blockquote.css" | .Page.Store.SetInMap "css" "blockquote" }}
{{ $emojis := dict
"caution" ":exclamation:"
"important" ":information_source:"
"note" ":information_source:"
"tip" ":bulb:"
"warning" ":information_source:"
}}
{{ if eq .Type "alert" }}
<blockquote class="alert alert-{{ .AlertType }}">
<p class="alert-heading">
{{ transform.Emojify (index $emojis .AlertType) }}
{{ with .AlertTitle }}
{{ . }}
{{ else }}
{{ or (i18n .AlertType) (title .AlertType) }}
{{ end }}
</p>
{{ .Text }}
</blockquote>
{{ else }}
<blockquote>
{{ .Text }}
</blockquote>
{{ end }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment