The v0.108.0 release of Hugo allows you, with the appropriate configuration and render hook, to add markdown attributes to stand-alone images, and/or wrap an image within a figure
element while generating syntactically correct HTML.
But I suspect that many are not aware of how powerful markdown attributes can be. Use markdown attributes with block quotes, headings, horizontal rules, lists (dl
, ol
, and ul
), paragraphs, and tables.
For example…
Site configuration
[markup.goldmark.parser.attribute]
block = true # default is false
Markdown
> This is a note.
{.note}
> This is a warning.
{.warning}
> This is dangerous.
{.danger}
Result
The alternative is verbose
{{< admonition "note" >}}
This is a note.
{{< /admonition>}}
{{< admonition "warning" >}}
This is a warning.
{{< /admonition>}}
{{< admonition "danger" >}}
This is dangerous.
{{< /admonition>}}
And you don’t need to create a shortcode.
Sass used in the example above
.danger,
.note,
.warning {
background: #efefef;
border-left-style: solid;
border-left-width: 0.4rem;
border-radius: 0.2rem;
margin-left: 0;
> p {
padding: 0.5rem 1rem;
}
}
.warning {
border-left-color: #ffbb00;
}
.note {
border-left-color: #0000ee;
}
.danger {
border-left-color: #ee0000;
}