Markdown attributes may be used with most block-level elements, but not with inline elements. Images and anchors (links) are inline elements.
attribute
Enable custom attribute support for titles and blocks (emphasis mine) by adding attribute lists inside single curly brackets…
With Hugo in its default configuration, these are the block-level HTML elements that may be represented with markdown. Note that markdown attributes cannot be used with dd
, dt
, or li
elements.
Element | Description | Accepts markdown attributes[1] |
---|---|---|
blockquote |
Block quotation | ![]() |
dd |
Describes a term in a description list | ![]() |
dl |
Description list | ![]() |
dt |
Description list term | ![]() |
h1 - h6 |
Heading | ![]() |
hr |
Horizontal rule | ![]() |
li |
List item | ![]() |
ol |
Ordered list | ![]() |
p |
Paragraph | ![]() |
pre |
Preformatted text[2] | ![]() |
table |
Table | ![]() |
ul |
Unordered list | ![]() |
Examples
> Able was I ere I saw Elba.
{.foo}
Able
: Having the power, skill, means, or opportunity to do something.
Elba
: A Mediterranean island in Tuscany, Italy.
{.foo}
## Heading Level 2 {.foo}
---
{.foo}
1. Ordered list item 1
1. Ordered list item 2
{.foo}
This is a paragraph.
{.foo}
```text {.foo}
A fenced code block
```
Name|Type
:--|:--
Felix|Cat
Spot|Dog
{.foo}
- Unordered list item 1
- Unordered list item 2
{.foo}
Also note that using an image render hook to produce a figure
element will result in invalid HTML. You cannot place a figure
element within a p
element. See this discussion.