Shortcodes Reference

Hugo shortcodes extend Markdown with custom components.

  • Use {{< >}} with percent delimiters for shortcodes that process inner content as Markdown.
  • Use angle bracket delimiters for raw HTML shortcodes.

Table

Define column widths for Markdown tables.

Use colon-separated numbers. Percentages are calculated automatically:

<div id="tbl-0" class="table-wrapper">
<table>
  <thead>
      <tr>
          <th>Name</th>
          <th>Description</th>
          <th>Status</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Feature</td>
          <td>A long description here</td>
          <td>Active</td>
      </tr>
  </tbody>
</table>

</div>
<style>
#tbl-0 table {
  table-layout: fixed;
  display: table;
  width: 100%;
}
#tbl-0 table th:nth-child(1),
#tbl-0 table td:nth-child(1) {
  width: 0.3333%;
}
#tbl-0 table th:nth-child(2),
#tbl-0 table td:nth-child(2) {
  width: 0.5000%;
}
#tbl-0 table th:nth-child(3),
#tbl-0 table td:nth-child(3) {
  width: 0.1667%;
}
</style>

Renders as a 3-column table with widths 33.33%, 50%, 16.67%.

Percent Syntax (legacy)

Comma-separated percentage values:

<div id="tbl-1" class="table-wrapper">
<table>
  <thead>
      <tr>
          <th>Name</th>
          <th>Description</th>
          <th>Status</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Feature</td>
          <td>A long description here</td>
          <td>Active</td>
      </tr>
  </tbody>
</table>

</div>
<style>
#tbl-1 table {
  table-layout: fixed;
  display: table;
  width: 100%;
}
#tbl-1 table th:nth-child(1),
#tbl-1 table td:nth-child(1) {
  width: 20%;
}
#tbl-1 table th:nth-child(2),
#tbl-1 table td:nth-child(2) {
  width: 60%;
}
#tbl-1 table th:nth-child(3),
#tbl-1 table td:nth-child(3) {
  width: 20%;
}
</style>

Auto Layout

Omit cols to use browser auto-sizing based on content:

<table>
  <thead>
      <tr>
          <th>Key</th>
          <th>Value</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Name</td>
          <td>Demo</td>
      </tr>
  </tbody>
</table>

Parameters

ParameterRequiredDescription
colsNoColumn widths. Ratio ("2:3:1") or percent ("20%,60%,20%").

Embed

Embed external pages via iframe (desktop) or link card (mobile).


https://example.com
ParameterDefaultDescription
url(required)Page URL to embed.
titleSame as urlDisplay title.
height"600"Iframe height in pixels.

Mermaid

Render Mermaid diagrams with dark mode support.



graph LR A[Start] --> B{Decision} B -->|Yes| C[Action] B -->|No| D[End]

Mermaid JS is loaded once per page. Diagrams re-render on theme toggle.


Tips

Colored callout boxes with four severity levels.


Did you know?

This is an informational tip.

Caution

Be careful with this setting.

Types

TypeColorUse case
infoBlueHelpful notes
warnYellowWarnings
errorRedError messages
successGreenSuccess confirmations

Parameters

ParameterPositionRequiredDescription
type1stYesOne of info, warn, error, success
title2ndNoBold heading text

Figure

Enhanced image with optional caption, link, and attribution.

A beautiful sunset
            Sunset

A beautiful sunset

Parameters

ParameterDefaultDescription
src(required)Image source URL.
altAlt text. Falls back to caption.
linkSame as srcClick-through URL.
target"_blank"Link target.
relLink rel attribute.
titleImage title.
captionCaption below image (Markdown supported).
attrAttribution text.
attrlinkAttribution link URL.
widthImage width.
heightImage height.
class"image-container"CSS class for wrapper.

Plist

Property list rendered as a key-value table.

Name Alice
Age 30
City Beijing

Renders as a two-column table with keys as header cells and values as data cells (Markdown supported).


Raw

Output inner content as raw HTML, bypassing Markdown processing.



Hello world

Video

Embed an autoplay looping video.


The video element fills 100% width with controls, muted playback, looping, and autoplay enabled.