Figure
Example
With this markup:
{{< figure
src="/images/examples/zion-national-park.jpg"
alt="A photograph of Zion National Park"
link="https://www.nps.gov/zion/index.htm"
caption="Zion National Park"
class="ma0 w-75"
>}}
Hugo renders this HTML:
<figure class="ma0 w-75">
<a href="https://www.nps.gov/zion/index.htm">
<img
src="/images/examples/zion-national-park.jpg"
alt="A photograph of Zion National Park"
>
</a>
<figcaption>
<p>Zion National Park</p>
</figcaption>
</figure>
Which looks like this in your browser:
Arguments
- src
- (
string
) Thesrc
attribute of theimg
element. Typically this is a page resource or a global resource.
- alt
- (
string
) Thealt
attribute of theimg
element. - width
- (
int
) Thewidth
attribute of theimg
element. - height
- (
int
) Theheight
attribute of theimg
element. - loading
- (
string
) Theloading
attribute of theimg
element. - class
- (
string
) Theclass
attribute of thefigure
element. - link
- (
string
) Thehref
attribute of the anchor element that wraps theimg
element. - target
- (
string
) Thetarget
attribute of the anchor element that wraps theimg
element. - rel
- (
rel
) Therel
attribute of the anchor element that wraps theimg
element. - title
- (
string
) Within thefigurecaption
element, the title is at the top, wrapped within anh4
element. - caption
- (
string
) Within thefigurecaption
element, the caption is at the bottom and may contain plain text or markdown. - attr
- (
string
) Within thefigurecaption
element, the attribution appears next to the caption and may contain plain text or markdown. - attrlink
- (
string
) Thehref
attribute of the anchor element that wraps the attribution.
Image location
The figure
shortcode resolves internal Markdown destinations by looking for a matching page resource, falling back to a matching global resource. Remote destinations are passed through, and the render hook will not throw an error or warning if unable to resolve a destination.
You must place global resources in the assets directory. If you have placed your resources in the static directory, and you are unable or unwilling to move them, you must mount the static directory to the assets directory by including both of these entries in your site configuration:
hugo.
module:
mounts:
- source: assets
target: assets
- source: static
target: assets
[module]
[[module.mounts]]
source = 'assets'
target = 'assets'
[[module.mounts]]
source = 'static'
target = 'assets'
{
"module": {
"mounts": [
{
"source": "assets",
"target": "assets"
},
{
"source": "static",
"target": "assets"
}
]
}
}