Cards
Cards lay out a few parallel destinations so the reader can pick one at a
glance: where to start, what to read next, which of three paths fits. Each card
is a linked title with a sentence under it, and the grid adapts to the width
of the page. A plain Markdown link list with {.cards} under it is all it
takes, so the source stays an ordinary list on GitHub. Do not use cards for
prose, which reads better as paragraphs, or for image collections, which
belong in a gallery. A section’s own landing page
usually needs no hand-written cards at all, because the theme can generate
them from the child pages (automatic cards).
Shortest form
Put {.cards} on the line after a link list. Each link becomes a card title,
and the text after — becomes its description:
- Get started — Start with OINK Starter, preview locally, then replace the site details with your own.
- Authoring — How pages are organized and which front matter keys exist.
- Customization — Navigation, search, branding, languages.
The whole card is the click target, not just the title. The number of columns
follows the available width, down to one on a phone, so there is no
columns parameter.
Title-only cards
The description is optional: one link per item is enough.
Loose lists and longer descriptions
When a description needs more than a sentence, write a loose list: the link in
one paragraph, the description in the next, and a blank line between items.
The title then sits on its own line above the description. {.cards} still
goes directly under the last paragraph, with no blank line in between.
-
Every page parameter is defined here exactly once: type, default, accepted values, and the page that explains it.
-
Site parameters grouped by feature, each row linking back to the guide that explains it.
Single-column list
For a directory of resources, where readers scan down rather than across,
write {.cards .td-cards-list} instead of {.cards}. The cards become one
column inside a single frame, separated by dividers, and each row grows with
its description. The shortcode form takes cards variant="list" for the same
result; any other variant warns and keeps the grid.
Component presentation shows the grid
and the list one after the other.
Icons and badges
A link list cannot carry icons, badges, images or a description with several
paragraphs; the cards and card shortcodes can. icon is exactly one Font
Awesome class pair, and badge is a short plain-text label beside the title.
Use OINK Starter and establish a local preview before customizing.
A release card from release_url and date, plus a checksums block for download assets.
Site-wide shortcuts and focus order.
An icon that is not a single class pair such as fa-solid fa-rocket warns,
and the card renders without it.
Markdown bodies
The body of a card is ordinary Markdown, so it can hold inline code,
emphasis, links and lists. Parameters such as title and badge are plain
text.
hugo mod get github.com/pgsty/oink. The recommended way; upgrading is one
version line.
No Go installation needed:
git submodule add- the theme lands in
themes/oink
A card without link, like these two, shows its title in bold and links
nowhere.
Cards with images
image puts a picture at the top of the card. It is looked up like
: page resource, then the current section’s resources, then a
global resource in assets/, then a static path such as /images/…, then a
remote URL. Local images carry their width and height, so the page does not
jump while they load.
Every image needs exactly one of image_alt="…", for an image that carries
information, or decorative=true, for one that is only ornament. With both,
the build warns and keeps the alt text; with neither, it warns and treats the
image as decorative.
Sidebar, article, table of contents — each can be turned off on its own.
A decorative cover: decorative=true emits an empty alt and screen readers skip it.
Card images do not open in the image zoom dialog, because clicking anywhere on the card already follows its link.
Automatic cards on section pages
A section’s landing page (_index.md) can list its child pages as cards with
no list in the source: the theme builds one card per child from its title,
description and icon. This site turns that on for every section:
A section can choose differently in its own front matter, and cascade passes
the choice down to its whole subtree:
Generated and hand-written cards share the same styles; only the source of the data differs. Let the theme list a section’s child pages, because a hand-written list drifts out of step with the sidebar as pages are added or renamed. Write cards by hand for anything else, such as external links or recommendations from other sections. Configuration defines these keys.
Which form to use
| What you want | Which form |
|---|---|
| A grid of links with one-sentence descriptions | {.cards} link list |
| Icons, badges, images | cards / card shortcode |
| Lists, code or several paragraphs in the description | cards / card shortcode |
| A card with no link | cards / card shortcode |
| This section’s child pages | nothing at all — section_index: cards |
Use the link list whenever it can hold your content: it still reads as a list of links on GitHub, while shortcodes do not.
Output
Cards are pure CSS and load no script. In print, link-list cards stack in one
column, shortcode cards fall back to two columns, and no card breaks across a
page. In the page’s Markdown output, a link list stays as written and each
shortcode card becomes a line - [Title](link) (badge) — description.
Parameter reference
The native form:
card parameters (cards itself takes only an optional variant="list"):
There is no cols, columns, accent, desc or color parameter. Unknown
parameters warn and are ignored.
Limits
{.cards}works on unordered lists only; on a numbered list it does nothing.{.cards}must sit directly under the list. A blank line before it, or indentation that puts it inside the last item, loses the marker without a warning: the build succeeds and the list stays a list. When no grid appears, check that line first.- A
cardoutsidecards, alone or inside another shortcode, warns and is skipped. - Only automatic section cards take a column count, through
params.ui.section_index_columns; hand-written grids always follow the width. - A description longer than two lines belongs in a paragraph or a callout.
Related
- Fields — also has a native form and a shortcode form
- Galleries — a grid of images
- Badges — inline status labels
- Organizing content — sections, weights and landing pages
- Configuration —
section_indexand friends