Media

Icy reads image sizes at build time, adds responsive WebP versions and a blurred placeholder, and opens images in a built-in viewer. Audio and video players use the browser’s own controls until JavaScript loads the theme’s.

Where files live

Every media path, in a shortcode or a Markdown image, is looked up in this order:

  1. The page bundle: photo.jpg next to the page’s index.md.
  2. assets/: images/photo.jpg for assets/images/photo.jpg.
  3. Another page’s bundle, by site path: /posts/images-and-galleries/lake-boats.webp.
  4. static/, by site path: /images/photo.jpg for static/images/photo.jpg.
  5. A remote URL.

A local path that matches nothing fails the build.

Images from the first three places get WebP versions from 480 to 2400 pixels wide and a placeholder. Images in static/ only have their size read. SVG and GIF files are used as they are.

Remote images

Remote images are downloaded at build time, processed like local ones and served from your site. Readers never contact the original host. Remote audio and video are linked as they are.

If a download fails, the image links to its original URL without a size or placeholder, and the build logs an icy-remote-fetch warning: see Network access. So that the page doesn’t shift even then, give remote images a size with figure:

markdown
{{< figure src="https://images.example.com/lake.jpg" alt="A lake at dawn" width="1600" height="1067" >}}

Markdown images

An image on a line of its own becomes a figure, with its title as the caption.

Rowing boats on a turquoise mountain lake
Boats waiting on a mountain lake
markdown
![Rowing boats on a turquoise mountain lake](/posts/images-and-galleries/lake-boats.webp "Boats waiting on a mountain lake")

If every image renders small and inline instead, add the Markdown settings from Getting started. A {.class} line after the image adds a class to the figure.

An image inside a sentence is drawn at text height, like an icon. Hovering or tapping it shows an enlarged copy.

A poppy Orange poppies sits in this sentence.

markdown
A poppy ![Orange poppies](/posts/images-and-galleries/orange-flowers.webp) sits in this sentence.

Image viewer

Click an image to open it in the viewer. All images on a page form one sequence: try it on any photo here.

  • Arrow keys, Home, End or a swipe move between images.
  • Esc or a click on the backdrop closes the viewer.
  • Without JavaScript, a click opens the full-size file.
ParameterDefaultDescription
params.article.imageViewertruefalse turns the viewer off site-wide.

A single image opts out with zoom=false on its figure. Linked images never open in the viewer. Live photos have their own setting: see Live photos.

Cover images

An article shows a cover under its header. Icy takes the first entry of front matter images, or, when there is none, a bundle image whose name contains cover or feature.

toml
+++
title = 'A walk by the lake'
images = ['cover.jpg']
+++
ParameterDefaultDescription
params.article.covertruefalse hides covers site-wide.
hideCover in front matterfalsetrue hides this page’s cover.

A remote URL in images is used for social previews only, not as a cover. Protected posts never show or share a cover.

Figures

One image with an optional title and caption, handled like a Markdown image. It replaces Hugo’s built-in figure.

A river in Yosemite Valley at dawn, with cliffs in a pink haze
Yosemite Valley The caption supports Markdown.
markdown
{{< figure src="/posts/images-and-galleries/yosemite-river.webp" alt="A river in Yosemite Valley at dawn, with cliffs in a pink haze" title="Yosemite Valley" caption="The caption supports **Markdown**." >}}
ParameterDefaultDescription
srcrequiredThe image.
alt""Alternative text.
title—Bold title at the start of the caption.
caption—Caption. Markdown.
link—URL the image links to, instead of opening the viewer.
aligncenterleft or right puts a narrow image against that edge. Text doesn’t wrap around it.
class—Extra class on the <figure>.
width, heightFrom the fileRequired for SVG, recommended for remote images.
zoomparams.article.imageViewerfalse keeps this image out of the viewer.
zoomSrcsrcA larger image for the viewer.

Photos in justified rows: each row fills the width, and its photos share one height. The layout needs no JavaScript.

markdown
{{< gallery caption="Three places" >}}
  {{< gallery-item src="/posts/images-and-galleries/atitlan-path.webp" alt="A path through purple flowers to Lake Atitlán, with volcanoes under a violet sunset sky" >}}
  {{< gallery-item src="/posts/images-and-galleries/foggy-summit.webp" alt="Green cliffs and a winding road under drifting fog at sunrise" caption="Each photo can have a caption" >}}
  {{< gallery-item src="/posts/images-and-galleries/blue-ranges.webp" alt="Layers of blue mountain ridges fading into haze" >}}
{{< /gallery >}}

gallery:

ParameterDefaultDescription
columnsautoPhotos per row, 1 to 4. auto: one row for one or two photos, two per row for four, otherwise three.
caption—Caption for the whole gallery. Markdown.
label—Accessible name when there is no caption.

gallery-item, directly inside gallery:

ParameterDefaultDescription
srcrequiredThe image.
alt""Alternative text.
caption—Caption under the photo. Markdown.
link—URL the photo links to, instead of opening the viewer.
width, heightFrom the fileThe photo’s size.
ratio—Aspect ratio such as 4/3, instead of a size.
zoomSrcsrcA larger image for the viewer.
loadinglazylazy or eager.

The layout needs each photo’s proportions. A photo whose size can’t be read, such as an SVG or a remote image, needs width and height or ratio, or the build fails.

Live photos

A still photo paired with a short video, like a phone’s Live Photo. Hover over it, long-press it, or press LIVE.

Yogurt, the cat
Yogurt, two seconds of her
markdown
{{< live-photo src="/posts/live-photos/yogurt.jpg" video="/posts/live-photos/yogurt.mp4" alt="Yogurt, the cat" caption="Yogurt, two seconds of her" >}}
ParameterDefaultDescription
srcrequiredThe still image.
videorequiredThe video.
alt""Alternative text for the still.
caption—Caption. Markdown.
width, heightFrom the fileThe still’s size.
zoomparams.livePhoto.zoomtrue lets a click open the still in the viewer.
  • Hovering plays the video muted, unless the reader prefers reduced motion. A long press or LIVE plays it with sound.
  • Nothing of the video is downloaded until it plays. Without JavaScript only the still shows.
  • A live photo stands on its own. Inside a gallery it fails the build.

To make every live photo open in the viewer, set:

hugo.toml
[params.livePhoto]
  zoom = true

From a phone

iPhones save a Live Photo as a HEIC image and a MOV clip. Android phones save a motion photo as one JPEG with the video inside. PicForge turns either into a still and an MP4 in your browser.

Put both files in the post’s bundle:

markdown
{{< live-photo src="still.jpg" video="motion.mp4" alt="…" >}}

Both can also be remote URLs. The still is then downloaded like any remote image, and the video streams from its host.

Music

A single-track player. The cover is the play button.

Gymnopédie No. 1 Robin Alciatore

Original by Erik SatieRecorded January 21, 2008

This file can't be played. Open it directly

markdown
{{< music src="/posts/audio-and-video/morning.m4a" title="Gymnopédie No. 1" artist="Robin Alciatore" original="Erik Satie" cover="/posts/audio-and-video/cover-morning.jpg" date="2008-01-21" >}}
ParameterDefaultDescription
srcrequiredThe audio file.
titleFile nameTrack title.
artist—Performer.
coverMusic iconCover image, cropped to a square.
original—Original artist, shown as “Original by …”.
date—Recording date, such as 2008-01-21 or 2008-01-21 18:30.
device—Recording device.

Only one player on a page sounds at a time: starting one pauses the others.

Playlists

A track list read from a data file. Tracks play one after another, and broken ones are skipped.

Piano pieces

  1. Nocturne in F major, Op. 15 No. 1 Luke Faulkner

    Original by Frédéric ChopinRecorded October 14, 2015

    This file can't be played. Open it directly

  2. Nocturne in E minor, Op. 72 No. 1 Peter Johnston

    Original by Frédéric ChopinRecorded August 13, 2014

    This file can't be played. Open it directly

  3. Gymnopédie No. 1 Robin Alciatore

    Original by Erik SatieRecorded January 21, 2008

    This file can't be played. Open it directly

markdown
{{< playlist data="/posts/audio-and-video/playlist-en.yaml" label="Piano pieces" >}}
content/posts/audio-and-video/playlist-en.yaml
- title: Gymnopédie No. 1
  artist: Robin Alciatore
  src: morning.m4a
  cover: cover-morning.jpg
  date: 2008-01-21
  original: Erik Satie
- title: Nocturne in F major, Op. 15 No. 1
  artist: Luke Faulkner
  src: river.mp3
  cover: cover-river.jpg
  date: 2015-10-14
  original: Frédéric Chopin
- title: Nocturne in E minor, Op. 72 No. 1
  artist: Peter Johnston
  src: wind.mp3
  date: 2014-08-13
  original: Frédéric Chopin
ParameterDefaultDescription
datarequiredA YAML, JSON or TOML file, found like any media path.
label—Heading and accessible name of the list.
sortdatedate lists the newest recordings first, none keeps the file order.

The file is a list of tracks, or a map with a tracks list. Each track takes the music parameters, and src is required. Paths in the file resolve from the bundle the file is in.

Video

A player for MP4, WebM and other files the browser can play.

This file can't be played. Open it directly

A short clip with a poster
markdown
{{< video src="/posts/audio-and-video/clip.mp4" poster="/posts/audio-and-video/clip-poster.jpg" title="A short clip with a poster" >}}
ParameterDefaultDescription
srcrequiredThe video file.
poster—Poster image.
title—Caption, also the accessible name.
ratioPoster’s shape, or 16/9Aspect ratio such as 4/3. Without it, the frame adopts the video’s shape once it loads.
preloadmetadatametadata, none or auto.
autoplayfalsePlay on load. Implies muted.
loopfalseStart again at the end.
mutedfalseStart muted.

With the player focused, K or Space plays and pauses, M mutes and F toggles full screen.

YouTube

A YouTube embed that contacts Google only when the reader clicks. It replaces Hugo’s built-in youtube.

Big Buck Bunny, by the Blender Foundation
markdown
{{< youtube id="aqz-KE-bpKQ" title="Big Buck Bunny, by the Blender Foundation" start="30" >}}
ParameterDefaultDescription
idrequiredThe 11-character video id.
title—Caption, also the accessible name.
start—Start time in seconds.
end—End time in seconds.
posterYouTube’s thumbnailYour own poster image.
  • The thumbnail is downloaded at build time and served from your site. If that fails, the build logs an icy-remote-fetch warning and shows a plain poster. Set poster to avoid depending on the network.
  • On click, the player loads from youtube-nocookie.com. If YouTube can’t be reached, readers get a Retry button and a direct link.
  • Without JavaScript, the poster links to the video on YouTube.
  • Only the parameters above are accepted. A positional id or Hugo’s autoplay fails the build.