Skip to main content
Background Image

Shortcodes

Table of Contents

In addition to all the default Hugo shortcodes, Blowfish adds several additional features.

Alert
#

The alert shortcode outputs its content as a stylized message box within your article. It’s useful for drawing attention to important information that you don’t want readers to miss.

ParameterFunction
iconOptional Icon to display on the left side.
Default: exclamation triangle icon (See Icon shortcode for more details on using icons.)
iconColorOptional Icon color in basic CSS style.
Can be a hex value (#FFFFFF) or color name (white)
Determined by current color scheme by default.
cardColorOptional Card background color in basic CSS style.
Can be a hex value (#FFFFFF) or color name (white)
Determined by current color scheme by default.
textColorOptional Text color in basic CSS style.
Can be a hex value (#FFFFFF) or color name (white)
Determined by current color scheme by default.

The input content is written in Markdown, so you can format it as needed.

Example 1: No parameters

{{< alert >}}
**Warning!** This action is destructive!
{{< /alert >}}
Warning! This action is destructive!

Example 2: Unnamed parameter

{{< alert "twitter" >}}
Don't forget to [follow me](https://twitter.com/nunocoracao) on Twitter.
{{< /alert >}}
Don’t forget to follow me on Twitter.

Example 3: Named parameters

{{< alert icon="fire" cardColor="#e63946" iconColor="#1d3557" textColor="#f1faee" >}}
This is an error!
{{< /alert >}}
This is an error!

Article
#

The Article shortcode embeds an article into a markdown file. The link parameter should be the .RelPermalink of the file to be embedded. Note that if the shortcode references its parent file, it will not display anything. Note: If you’re running your site in a subfolder like Blowfish (i.e., /blowfish/), include that path in the link.

ParameterFunction
linkRequired .RelPermalink of the article to embed
showSummaryOptional Boolean indicating whether to show article summary. If not set, site’s default configuration will be used.
compactSummaryOptional Boolean indicating whether to show summary in compact mode. Defaults to false.

Example:

{{< article link="/posts/welcome-to-blowfish/" >}}

Badge
#

The badge shortcode can be used to display small badges and labels within your content.

Example:

{{< badge >}}
New article!
{{< /badge >}}
New article!

Button
#

The button shortcode generates a styled button that can link to other pages or external URLs.

ParameterFunction
hrefRequired URL or path to link to
targetOptional Link target (e.g., _blank)

Example:

{{< button href="https://github.com/nunocoracao/blowfish" target="_blank" >}}
Download Blowfish
{{< /button >}}
Download Blowfish

Chart
#

The chart shortcode uses Chart.js library to embed charts into articles using simple structured data.

Example:

{{< chart >}}
type: 'bar',
data: {
  labels: ['Tomatoes', 'Blueberries', 'Bananas', 'Cherries', 'Apples', 'Grapes', 'Oranges'],
  datasets: [{
    label: '# of votes',
    data: [12, 19, 3, 5, 3, 8, 1],
  }]
}
{{< /chart >}}

Figure
#

The figure shortcode replaces the default Hugo figure shortcode and provides additional functionality for displaying images with captions.

ParameterFunction
srcRequired Image source URL or path
altOptional Alternative text for the image
captionOptional Image caption
classOptional CSS class for styling
hrefOptional Link URL for the image
defaultOptional Use default Hugo figure behavior

Example:

{{< figure src="image.jpg" alt="Description" caption="Image caption" >}}

Gallery#

The gallery shortcode creates an image gallery from a directory of images.

Example:

{{< gallery >}}
<img src="gallery/01.jpg" class="grid-w33" />
<img src="gallery/02.jpg" class="grid-w33" />
<img src="gallery/03.jpg" class="grid-w33" />
{{< /gallery >}}

Icon
#

The icon shortcode displays icons from various icon libraries.

ParameterFunction
Icon nameRequired Name of the icon to display

Example:

{{< icon "github" >}}

Katex
#

The katex shortcode renders mathematical expressions using KaTeX.

Example:

{{< katex >}}
\\(f(a,b,c) = (a^2+b^2+c^2)^3\\)
{{< /katex >}}

Lead
#

The lead shortcode creates a lead paragraph that stands out from regular text.

Example:

{{< lead >}}
This is a lead paragraph that introduces the main content.
{{< /lead >}}
This is a lead paragraph that introduces the main content.

Mermaid
#

The mermaid shortcode allows you to draw detailed diagrams and flowcharts using Mermaid syntax.

Example:

{{< mermaid >}}
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
{{< /mermaid >}}

TypeIt
#

The typeit shortcode uses the TypeIt library to create typewriter-style animations.

Example:

{{< typeit >}}
This text will be typed out character by character.
{{< /typeit >}}

Best Practices
#

  1. Use alerts sparingly - Too many alerts can overwhelm readers
  2. Choose appropriate icons - Icons should be relevant to the content
  3. Test shortcodes - Always preview your content to ensure shortcodes render correctly
  4. Keep it simple - Don’t overuse shortcodes in a single article
  5. Consider accessibility - Ensure your shortcodes work well with screen readers

For more information about Hugo shortcodes, see the Hugo documentation.

No articles published here yet.