This page demonstrates all available shortcodes in the Hugo Narrow theme.

Hugo Built-in Shortcodes

Hugo provides several built-in shortcodes . The content of these shortcodes is subject to change without notice, so you can visit the official page for detailed usage instructions.

The built-in shortcodes include:

  • Details
  • Figure
  • Gist
  • Highlight
  • Instagram
  • Param
  • QR
  • Ref
  • Relref
  • Vimeo
  • X
  • YouTube

Theme Custom Shortcodes

Icon

Display SVG icons from the theme’s icon library:

MARKDOWN
{{< icon name="heart" >}}
{{< icon name="github" size="lg" >}}
{{< icon name="sun" class="text-primary" >}}
Click to expand and view more

Example:

Parameters:

  • name: Icon name (required) - Check assets/icons/ for available icons or place custom icons in this directory, or place the custom icon in this directory
  • size: xs, sm, md, lg, xl, 2xl (default: md)
  • class: Custom CSS class, which can be used to change colors

Button

Create styled buttons with theme colors:

MARKDOWN
{{< button text="Learn More" url="/about" >}}
{{< button text="GitHub" url="https://github.com" icon="github" target="_self" >}}
{{< button text="Download" url="/download" variant="outline" size="lg" >}}
Click to expand and view more

Example:

Primary Button Secondary Button Outline Button Small Size Medium Size Large Size With Icon External Link

Parameters:

  • text: Button text (required, or use inner content)
  • url: Link address (required)
  • variant: primary, secondary, outline (default: primary)
  • size: sm, md, lg (default: md)
  • icon: Theme icon name
  • target: _blank,_self (default: _blank)
  • rel: Link relationship (noopener noreferrer is automatically added when _blank is used)

Display a link card with a website icon:

MARKDOWN
{{< link title="Google" description="The world largest search engine." url="https://google.com" icon="https://google.com/favicon.ico" >}}
Click to expand and view more

Examples:

Bilibili

Embed Bilibili videos:

MARKDOWN
{{< bilibili BV号 >}}
{{< bilibili AV号 分P号 >}}
Click to expand and view more

Tencent Video

MARKDOWN
{{< tencent 视频ID >}}
Click to expand and view more

Create a waterfall-style image gallery:

MARKDOWN
{{< masonry >}}
![Image 1](/images/1.jpg)
![Image 2](/images/2.jpg)
![Image 3](/images/3.jpg)
{{< /masonry >}}
Click to expand and view more

Copyright Notice

Author: Hugo Narrow

Link: https://hugo-narrow.vercel.app/posts/shortcodes/

License: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

Start searching

Enter keywords to search articles

↑↓
ESC
⌘K Shortcut