@markand to give you an idea of how shortcodes might help with your use case:
Create the following at layouts/shortcodes/alert.html
:
<div class="alert alert-{{.Get 0}}" role="alert">{{.Get 1}}</div>
Then in your markdown files you can call this shortcode anywhere you want within the content/body copy for the file:
{{< alert "info" "This is a notice." >}}
This should then render as follows:
<div class="alert alert-info">This is a notice.</div>
If you want the added ability to write the copy for the alert in markdown, you can use the alternate shortcode syntax at layouts/shortcodes/alert.html
<div class="alert alert-{{.Get 0}}" role="alert">{{- .Inner -}}</div>
But you would then have to call the shortcode using the %
:
{{% alert "info" %}}
This is a **notice**.
{{% /alert %}}
Which would render as…
<div class="alert alert-info" role="alert">This is a <strong>notice</strong>.</div>