Shortcode to Add a Strikethrough

This is part of our Hugo shortcode series.

In this post we wanted to make a quick shortcode to add a strikethrough to some of our text. We use a very similar method to the raw html shortcode, but encompass it with the <stike> element.

Like this text here.

File: /layouts/shortcodes/strike.html

1
<strike>{{.Inner}}</strike>

Example Usage

1
Welcome to {{< strike >}}MakeWithHugo{{< /strike >}}

Output

1
<strike>MakeWithHugo</strike>

Welcome to MakeWithHugo


Site illustrations (of Hugo the rabbit) drawn by Carina Roberts.