Add or Edit Shortcodes

To modify a shortcode that comes built-in with the Sans theme (or Hugo itself), you should mirror the theme’s structure in your root directory.

  1. Identify the shortcode name in themes/sans/layouts/shortcodes/.
  2. Create a matching file in your project root: layouts/shortcodes/[name].html.
  3. Add your custom HTML and Go template logic.

ActionPath to EditResult
Modify Theme Shortcodelayouts/shortcodes/notice.htmlOverrides the theme's version
Modify Hugo Internallayouts/shortcodes/youtube.htmlOverrides the default Hugo YouTube embed
Table: Overriding Logic

Adding New Shortcodes

You can create custom components (like buttons, alerts, or specialized galleries) by adding new files to your local layouts folder.

Example: Creating a “Warning” Alert

Create layouts/shortcodes/alert.html:

HTML
1
2
3
<div class="custom-alert {{ .Get "type" }}">
  {{ .Inner | markdownify }}
</div>