Create alerts as shortcode or partial or in hugo.toml for global announcements.
info
Make it known: Alerts are fun to use for all!
The global alert
This is setup in your hugo.toml configuration file. Multiple banners will be displayed for however many [[params.alphaAlert]] blocks you configure.
[params]
isAlpha = true
[[params.alphaAlert]]
alertType = "danger"
alertTitle = "Special Banner add-on included"
alertMessage = "This theme is a work in progress!"
alertIconClass = "fa-solid fa-camera-retro"
dismissable = true
Features:
- Alert Types: Supports info, danger, success, warning, and a default dark type.
info(blue),success(green),warning(yellow),danger(red),dark(dark)- Icon Classes: Automatically assigns default icons based on the alert type but allows for custom icons if specified.
- Conditional Display: Only displays the alert box if there is either a title or a message.
- Default Values: Provides default values to avoid issues when variables are not set.
- Dismissable: Defaults to false, add true and it will have an x to close the alert box.
For alertIconClass any fontawesome-free icon class will work.
From the content directory, called as a shortcode.
All of the params are optional, but if neither alertTitle or alertMessage are passed they will not render. The alertIconClass must be a valid fontawesome icon class.
{{< alert-wrapper
alertType="info"
alertTitle="will"
alertMessage="robinson"
alertIconClass="fa-solid fa-snowflake"
dismissable=true
>}}
Alert shortcode examples:
Info
info
New feature available: Dark mode is now supported. Toggle it using the sun/moon icon in the header.
Success
success
Configuration saved: Your changes have been applied and will take effect on the next build.
Warning
warning
Heads up: This page uses the Leaflet shortcode which requires loadLeaflet = true in your front matter.
Danger
danger
Breaking change: The headerGradientClasses param has been replaced by twClasses.headerBackgroundFrameOuter. Update your config before upgrading.
Default (no type)
No alertType passed — renders with a neutral gray style. No alertIconClass either, so the default icon is used.
dark
Just so you know: This is a neutral alert with no type specified.
Dismissable alerts
Add dismissable="true" to any alert to show a close button. The user can dismiss it and it will not reappear.
{{< alert-wrapper
alertType="success"
alertTitle="All set"
alertMessage="You can dismiss this alert with the X button."
dismissable="true"
>}}
success
All set: You can dismiss this alert with the X button.