Usage
{{< cover [src = "img/hero.jpg"] [header = "Welcome"] [subtitle = "Saturday 7th November"] [text = "A short line of copy"] [link = "/about"] [class = "hero"] >}}Full-bleed cover band: an image or video behind an overlaid heading and text
Description
Renders a full-width band with a cover image or video behind a centred heading and paragraph. Raster images are resized to a srcset capped at the source’s native width, converted to WebP, and the original is never published. A scrim sits between the media and the text so the copy keeps its contrast over any photograph.
Parameters
indicates required parameter
src =
"string"
Path to the cover image or video, resolved by tk/get-asset (page bundle, then assets/, then static/). Omit for a text-only band.
alt =
"string"
Alt text for the image. Defaults to empty: a cover is decorative, and the heading beside it already carries the meaning.
header =
"string"
Heading text, rendered as the page h1.
subtitle =
"string"
A line under the heading, as a
<p class="pi-cover-subtitle"> rather than a heading. Emitted as HTML, so markup such as <sup> survives.text =
"string"
Body copy under the heading. Markdownified, so inline markdown works.
inner =
"string"
Extra content after the text, inside the overlay. Markdownified. The hw shortcode passes its inner content here.
innerHTML =
"string"
As inner, but emitted verbatim. Only for a partial calling tool/cover directly with rendered markup, which markdownify would turn into a code block wherever it is indented.
beforeHTML =
"string"
Markup emitted verbatim inside the section, before the overlay (
.pi-cover-inner). For a component at the top of the band in normal flow, e.g. an animated nav. It needs position:relative and z-index >= 1 to sit above the scrim.afterHTML =
"string"
As beforeHTML, emitted after the overlay: a component at the bottom of the band, e.g. a slider.
message =
"bool"true
Renders the page’s
hero-message: front matter (tool/hero-message) after the inner content, whenever this cover has a header. false turns it off, for a hero that places tool/hero-message itself.class =
"string"
Extra classes on the
<section>, so site CSS can restyle one cover. Select it as .pi-cover.your-class: the cover’s own style block comes later in the document and wins at equal specificity.link =
"string"
URL. When set, the heading becomes a link to it.
height =
"string"60svh
CSS length for the band’s min-height.
page =
"object"REQUIREDcurrent page
Hugo page context (automatically provided by the hw shortcode)
Examples
Cover image with a heading, some copy and a link
{{<hw t="cover" src="img/hero.jpg" header="Welcome" text="A minimal Hugo theme." link="/about">}}The heading becomes the link; the image stays decorative with empty alt
Text-only band, no image
{{<hw t="cover" header="Section break" text="Copy with **inline markdown**.">}}With no src the band renders as a plain centred panel
Full-screen hero with a subtitle, a site class and inner content
{{<hw t="cover" src="img/hero.jpg" header="Bonfire Night" subtitle="Saturday 7<sup>th</sup> November" class="hero" height="100svh">}}[Donate](/donate){{</hw>}}Style it from site CSS with .pi-cover.hero
Shorter band
{{<hw t="cover" src="img/hero.jpg" header="Compact" height="30svh">}}height takes any CSS length
Video cover
{{<hw t="cover" src="video/loop.mp4" header="In motion">}}Extensions in site.Params.extensions.video render as a muted, looping, inline video
Additional Information