2023-07-28 22:11:25 +01:00
---
title: Cards Component
linkTitle: Cards
---
## Example
{{< cards > }}
2023-09-13 04:49:01 -04:00
{{< card link = "../callout" title = "Callout" icon = "warning" > }}
2024-08-11 18:30:19 +02:00
{{< card link = "../callout" title = "Card with tag" icon = "tag" tag = "A custom tag" > }}
2023-07-28 22:11:25 +01:00
{{< card link = "/" title = "No Icon" > }}
{{< / cards > }}
2023-08-20 23:09:59 +01:00
{{< cards > }}
{{< card link = "/" title = "Image Card" image = "https://source.unsplash.com/featured/800x600?landscape" subtitle = "Unsplash Landscape" > }}
2023-09-18 19:04:48 -04:00
{{< card link = "/" title = "Local Image" image = "/images/card-image-unprocessed.jpg" subtitle = "Raw image under static directory." > }}
2023-09-23 19:25:51 +01:00
{{< card link = "/" title = "Local Image" image = "images/space.jpg" subtitle = "Image under assets directory, processed by Hugo." method = "Resize" options = "600x q80 webp" > }}
2023-08-20 23:09:59 +01:00
{{< / cards > }}
2023-07-28 22:11:25 +01:00
## Usage
```
{{< /* cards */>}}
2023-09-13 04:49:01 -04:00
{{< /* card link="../callout" title="Callout" icon="warning" */>}}
2024-08-11 18:30:19 +02:00
{{< /* card link="../callout" title="Card with tag" icon="warning" tag= "A custom tag" */>}}
2023-07-28 22:11:25 +01:00
{{< /* card link="/" title="No Icon" */>}}
{{< /* /cards */>}}
```
2023-08-20 23:09:59 +01:00
```
{{< /* cards */>}}
{{< /* card link="/" title="Image Card" image="https://source.unsplash.com/featured/800x600?landscape" subtitle="Unsplash Landscape" */>}}
2023-09-18 19:04:48 -04:00
{{< /* card link="/" title="Local Image" image="/images/card-image-unprocessed.jpg" subtitle="Raw image under static directory." */>}}
2023-09-23 19:25:51 +01:00
{{< /* card link="/" title="Local Image" image="images/space.jpg" subtitle="Image under assets directory, processed by Hugo." method="Resize" options="600x q80 webp" */>}}
2023-08-20 23:09:59 +01:00
{{< /* /cards */>}}
```
2023-09-18 19:04:48 -04:00
## Card Parameters
2024-08-11 18:30:19 +02:00
| Parameter | Description |
|----------- |-----------------------------------------------------------------|
| `link` | URL (internal or external). |
| `title` | Title heading for the card. |
| `subtitle` | Subtitle heading (supports Markdown). |
| `icon` | Name of the icon. |
| `tag` | Text in tag. |
| `tagColor` | Color of the tag: `gray` (default), `yellow` , `red` and `blue` . |
2023-09-18 19:04:48 -04:00
## Image Card
Additionally, the card supports adding image and processing through these parameters:
| Parameter | Description |
|----------- |---------------------------------------------|
| `image` | Specifies the image URL for the card. |
| `method` | Sets Hugo's image processing method. |
| `options` | Configures Hugo's image processing options. |
2023-09-23 19:25:51 +01:00
Card supports three kinds of images:
2023-09-18 19:04:48 -04:00
1. Remote image: the full URL in the `image` parameter.
2. Static image: use the relative path in Hugo's `static/` directory.
3. Processed image: use the relative path in Hugo's `assets/` directory.
Hextra auto-detects if image processing is needed during build and applies the `options` parameter or default settings (Resize, 800x, Quality 80, WebP Format).
It currently supports these `method` : `Resize` , `Fit` , `Fill` and `Crop` .
For more on Hugo's built in image processing commands, methods, and options see their [Image Processing Documentation ](https://gohugo.io/content-management/image-processing/ ).
2024-08-11 18:30:19 +02:00
## Tags
The card supports adding tags with custom text and colors:
{{< cards > }}
{{< card link = "../callout" title = "Card with default tag color" tag = "tag text" > }}
{{< card link = "../callout" title = "Card with red tag" tag = "tag text" tagColor = "red" > }}
{{< card link = "../callout" title = "Card with blue tag" tag = "tag text" tagColor = "blue" > }}
{{< card link = "../callout" title = "Card with yellow tag" tag = "tag text" tagColor = "yellow" > }}
{{< / cards > }}
```
{{< /* cards */>}}
{{< /* card link="../callout" title="Card with default tag color" tag= "tag text" */>}}
{{< /* card link="../callout" title="Card with default red tag" tag= "tag text" tagColor="red" */>}}
{{< /* card link="../callout" title="Card with blue tag" tag= "tag text" tagColor="blue" */>}}
{{< /* card link="../callout" title="Card with yellow tag" tag= "tag text" tagColor="yellow" */>}}
{{< /* /cards */>}}
```