Shortcodes

Instead of writing all your site pages from scratch, Hugo lets you define and use shortcodes.

Why shortcodes? While markdown is sufficient to produce simple pages, it's insufficient where complex page structures are needed. Thusly, whenever we need special styling, shortcodes compliment the shortcomings of markdown.

This way, you can side step complex html and css boilerplate in your content files.

Sometimes, the shortcode will wrap content, sometimes it won't. When content is wrapped, a closing shortcode tag is needed. Please see the link I provided above and the markdown files for examples. You'll get the gist pretty quickly.

I've setup the following shortcodes:

Block

Takes positional modifiers

Example

1...
2  {{< block "modifiers" >}}
3  <!-- Nest columns or content  -->
4  {{< /block >}}
5...

Column

It takes positional parameters

Example

1  {{< column "mt-2 mb-2" >}}
2  <!-- applied margin top and margin bottom modifiers -->
3  {{< /column >}}

Youtube Video

This allows you to embed a youtube video in you content. You would achieve that using a positional parameter (needs no name )parameter, like so:

Syntax

1  {{< youtube "25QyCxVkXwQ" >}}
2  <!-- Use the youtube video id -->

Result

OR

Syntax

1<!-- or use full url -->
2{{< youtube "https://www.youtube.com/watch?v=MmG2ah5Df4g" >}}

Result

Button

This adds a styled link (styled like a button). It takes two no-optional parameters:

PARAMETERPURPOSEOPTIONAL
labelbutton textno
urlbutton linkno
modifierstyling classesyes

Example

1  {{< button "/" "doe nu mee" >}}

Picture

You want to use darkmode images when darkmode is enabled on a device and a regular image on lightmode? It takes 3 positional parameter

Store these images in the static/images directory.

Syntax

1...
2{{< picture "lightModeImage.png" "darkModeImage.png" "Image alt text" >}}
3...

Result

Include inline galleries within your articles. These galleries can contain N number of images. It takes 2 positional parameters.

The 1st parameter is required. It's a comma-separated list (,) of your images' paths.

The 2nd parameter is optional. It's a double-collon-separated list (::) of your images' alt/description/captions text. It's always a good SEO practice to include alt text for your images.

Syntax

1...
2{{< gallery "images/painting.jpg,images/scribble.jpg,images/painting.jpg" "Gallery Image 1::gallery image 2::gallery image 1 copy" >}}
3...

For legibility, you may include a space after the delimiters , & ::

Result

Tip

Use this short if you want to publish informational tooltips that look like:

This tooltips may take either of the following forms:

Syntax

1{{< tip >}}
2Something of __interest__ you want to highlight
3{{< /tip >}}

Result

Something of interest you want to highlight

OR

Syntax

1{{< tip "warning" >}}
2Something of __interest__ the user should be careful about
3{{< /tip >}}

Result

Something of interest the user should be careful about