跳过正文

Media and Content Embeddings

查看源码 编辑此页 (外部链接)
首次發表:

Card 此标题的链接

The card shortcode renders a general-purpose preview card with a title, description, optional image or icon, and metadata.

ParameterDescription
titleRequired. Card heading text.
urlOptional. Link target for the whole card.
descOptional. Description text shown below the title. Supports HTML.
imageOptional. Thumbnail image URL. Falls back to a placeholder icon when omitted.
iconOptional. Icon name shown inline before the title.
metaTextOptional. Metadata content shown below the description. Supports HTML.

Example

{{< card
  title="Getting Started"
  url="https://example.com"
  desc="Description."
  image="/img/01.webp"
>}}

Article Card 此标题的链接

The article shortcode generates a visual preview card for a specified internal page.

ParameterDescription
pathRequired. The logical path of the target internal page.
descOptional. Whether the page description is displayed.
metaOptional. Whether the page metadata is displayed.
langOptional. Get page from another language of your site.

Example

{{< article path="/docs/40-getting-started" desc=true meta=false >}}

GitHub Card 此标题的链接

The github shortcode creates a dynamic preview card for a GitHub repository.

ParameterDescription
repoRequired. Format owner/repo.

Example: Repository preview with thumbnail

{{< github repo="gohugoio/hugo" >}}

Email 此标题的链接

The email shortcode obfuscates an email address to reduce exposure to scrapers. The address is base64-encoded at build time and decoded client-side into a mailto link.

ParameterDescription
addressRequired. Email address.

Example

{{< email address="hello@example.com" >}}
Email placeholder

Embed Code 此标题的链接

The embed-code shortcode fetches source code from a remote URL and renders it as a highlighted code block.

ParameterDescription
urlRequired. The absolute URL of the remote source file.
typeOptional. The programming language for syntax highlighting.
linesOptional. Line range in start-end format (e.g. 3-7), or a single line number. Omit to include the entire file.

Example: Fetching specific lines from GitHub

{{< embed-code url="https://raw.githubusercontent.com/githubtraining/hellogitworld/refs/heads/master/src/main/java/com/github/App.java" type="java" lines="3-7" >}}
/**
 * Hello again
 * Hello world!
 * Hello
 */

Embed Markdown 此标题的链接

The embed-md shortcode fetches and renders remote Markdown content. This shortcode must be called with markdown notation ({{/*% %*/}})

ParameterDescription
urlOptional. The absolute URL of the Markdown file.
pageOptional. The logical path of the target internal page.

Example

Include an external page:

{{% embed-md url="https://github.com/ZhenShuo2021/hugo-yore/raw/refs/heads/main/README.md" md=false %}}

Include an internal page:

{{% embed-md page="/docs/shortcodes/40-math/index.md" %}}

Fig 此标题的链接

The fig shortcode renders an image inside a <figure> element with a figcaption that supports footnotes. Use it only when the caption needs a footnote, otherwise use standard Markdown image syntax.

ParameterDescription
srcRequired. Image path.
altOptional. Alt text for the image.
captionOptional. Caption text shown in the figcaption.
attrsOptional. Raw HTML attributes applied to the <figure> element.

Example

{{% fig
  attrs="class='center-cap center-img' style='width:50%'"
  src="/img/04.webp"
  alt="alt"
  caption="*1234*[^fn_a]"
%}}

[^fn_a]: Footnote text.
alt

12341

This is equivalent to the standard markdown image syntax below, but the syntax does not support footnotes.

![alt](/img/04.webp "*1234*")
{class="center-cap center-img" style="width:50%"}

Float 此标题的链接

alt

The float shortcode wraps arbitrary content with text flowing around it, floating left or right with configurable width.

ParameterDescription
sideOptional. Float direction, start or end. Default: start
sizeOptional. Float width, s, m, or l. Default: m

Example:

{{% float side="end" %}}

![alt](/img/04.webp)

{{% /float %}}

Use {{% float-clear %}} to cancel the float effect.

Cols 此标题的链接

cols shortcode allows you to create flexible multi-column layouts with custom widths and optional responsive behaviors. Note that it uses markdown notation ({{% %}}).

ParameterDescription
widthsOptional. Comma-separated list of column widths (e.g., 30%,70%). If not specified, columns are evenly distributed.
rwdOptional. Responsive web design (rwd) controls responsive behavior. When true, columns stack vertically on small screens and display horizontally on larger screens. Default: true
{{% cols widths="70%,30%" rwd=false %}}

![qwe](/img/01.webp)

<!-- cell -->

Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit.

{{% /cols %}}
qwe

Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit.

The carousel shortcode displays an image carousel with a main viewport, navigation buttons, and a scrollable thumbnail strip. The inner content uses YAML format to define images.

Images can be specified individually with src, or batch-loaded with match.

ParameterDescription
srcOptional. YAML path to the image configuration file. Takes precedence over the shortcode's inner content.
ratioOptional. Aspect ratio of the slide frame, in x/y format. Default: 4/3
fitOptional. How images fill the frame. contain shows the full image (may letterbox); cover crops to fill. Default: contain
thumbsOptional. Whether to show the thumbnail strip. Default: true
arrowsOptional. Whether to show the previous/next buttons. Default: true
counterOptional. Whether to show the slide counter. Default: true

YAML fields per item:

FieldDescription
srcImage path.
matchGlob pattern to batch-load images. See Match (外部链接) for more details.
captionOptional. Caption text displayed below the main image.
altOptional. Alt text for accessibility. Falls back to caption if omitted.

Example 1: fit="cover" arrows=false

{{< carousel ratio="32/9" fit="cover" arrows=false >}}

- match: /img/*[5-7]* # 05, 06, 07
- src: /img/drop.svg
  caption: carousel caption
  alt: carousel alt

{{< /carousel >}}

Example 2: thumbs=false counter=false

{{< carousel ratio="32/9" thumbs=false counter=false >}}

- match: /img/*[5-7]* # 05, 06, 07
- src: /img/drop.svg
  caption: carousel caption
  alt: carousel alt

{{< /carousel >}}

Masonry 此标题的链接

masonry shortcode allows you to create a fluid, masonry-style image wall where items are arranged in columns with varying heights. The inner content uses YAML format to define images.

ParameterDescription
srcOptional. YAML path to the image configuration file. Takes precedence over the shortcode's inner content.
maxColsOptional. The maximum number of columns to display. Default: 3

Images can be specified individually with src, or batch-loaded with match.

YAML fields per item:

FieldDescription
srcImage path.
matchGlob pattern to batch-load images. See Match (外部链接) for more details.
captionOptional. Caption text displayed below the image.
altOptional. Alt text for accessibility. Falls back to caption if omitted.
widthOptional. Image width to prevent layout shift
heightOptional. Image height to prevent layout shift

Example

{{< masonry maxCols="3" >}}

- src: /img/02.webp
  alt: Fly high
  caption: Hello world!
- src: /img/03.webp
  alt: Contrails
- src: /img/04.webp
  alt: Parapet
- src: /img/05.webp
  alt: Wing
- src: /img/06.webp
  alt: Eaves
- src: /img/07.webp
  alt: Biplane sunset
- src: /img/drop.svg
  alt: SVG sample

{{< /masonry >}}

Icon 此标题的链接

The icon shortcode renders an inline SVG icon from the theme's icon library.

ParameterDescription
0Required. Icon name.

Example

{{< icon "activity" >}}
{{< icon "arrow-left-circle" >}}
{{< icon "clock" >}}

See all available icons in reference page.

Audio 此标题的链接

The audio shortcode embeds a HTML5 audio player.

ParameterDescription
srcRequired. Audio path.
posterOptional. Poster path. If omitted, the shortcode attempts a same-name image in the page bundle.
altOptional. Alt text for the cover image.
captionOptional. Markdown caption shown below the player.
autoplayOptional. Enables autoplay when true. Default: false
loopOptional. Loops when true. Default: false
mutedOptional. Mutes when true. Default: false
controlsOptional. Shows the browser's default playback controls when true. Default: true
preloadOptional. metadata (load info), none (save bandwidth), or auto (preload more). Default: metadata
startOptional. Start time in seconds.
endOptional. End time in seconds.
ratioOptional. Reserved aspect ratio for the cover image, only applied when poster is set. Supports 16/9, 4/3, 1/1, or custom W/H. Default: 1/1
fitOptional. How the cover image fits the ratio: contain (no crop), cover (crop to fill), fill (stretch). Default: contain

Example: Looped muted audio

{{< audio
  src="/audio/beep.mp3"
  caption="*beep*"
  loop=true
>}}
beep

Video 此标题的链接

The video shortcode embeds a HTML5 video player.

ParameterDescription
srcRequired. Video path.
posterOptional. Poster path. If omitted, the shortcode attempts a same-name image in the page bundle.
captionOptional. Markdown caption shown below the video.
autoplayOptional. Enables autoplay when true. Default: false
loopOptional. Loops when true. Default: false
mutedOptional. Mutes when true. Default: false
controlsOptional. Shows the browser's default playback controls when true. Default: true
playsinlineOptional. Inline playback on mobile when true. Default: true
preloadOptional. metadata (load info), none (save bandwidth), or auto (preload more). Default: metadata
startOptional. Start time in seconds.
endOptional. End time in seconds.
ratioOptional. Reserved aspect ratio for the player. Supports 16/9, 4/3, 1/1, or custom W/H. Default: 16/9
fitOptional. How the video fits the ratio: contain (no crop), cover (crop to fill), fill (stretch). Default: contain

Example: Autoplay muted video

{{< video
    src="https://upload.wikimedia.org/wikipedia/commons/5/5a/CC0_-_Public_Domain_Dedication_video_bumper.webm"
    caption="*Public domain demo*"
    loop=true
    muted=true
>}}
Public domain demo

PDF 此标题的链接

The pdf shortcode embeds a PDF file using an inline iframe viewer.

ParameterDescription
srcRequired. PDF URL or local path. Resolves as page resource first, then global resource, then relative URL.
titleOptional. PDF title for screen readers.
pageOptional. Jumps to a specific page number on load.
heightOptional. Height of the viewer frame. Default: 800px

YouTube 此标题的链接

The youtube shortcode embeds an optimized YouTube video player.

ParameterDescription
idOptional. YouTube video ID.
paramsOptional. URL parameters.

Example: Specific video with start time

{{< youtube id="ldX1Ii0MofQ" params="start=30" >}}

TypeIt 此标题的链接

The typeit shortcode creates dynamic typewriter animations.

ParameterDescription
initialStringOptional. Text shown before animation.
speedOptional. Typing speed in ms. Default: 100
loopOptional. Whether to restart. Default: false
tagOptional. HTML tag for wrapping. Default: div

Example: Looping animation with custom speed

{{< typeit speed="50" loop="true" tag="h2" >}}
Yore - A Simple Yet Powerful Hugo Theme
{{< /typeit >}}


  1. Footnote text. ↩︎

文章关联

无障碍设定

字体大小