Skip to content

Hugo Shortcode Error Fix

DodaTech Updated 2026-06-24 1 min read

In this tutorial, you'll learn about Hugo Shortcode Error Fix. We cover key concepts, practical examples, and best practices.

The Problem

ERROR: ".../content/post.md:20:1": failed to extract shortcode:
template for shortcode "faq" not found

Hugo shortcodes require template files in layouts/shortcodes/. If the template is missing, Hugo throws a build error.

Wrong

{{</* faq */>}}

Output: ERROR: template for shortcode "faq" not found

The shortcode template layouts/shortcodes/faq.html does not exist.

Create layouts/shortcodes/faq.html:

{{ .Inner }}

Or use a shortcode that exists in your theme:

{{</* highlight python */>}}
print("hello")
{{</* /highlight */>}}

Output: syntax-highlighted code block

Prevention

  • Verify shortcode names match template filenames exactly
  • Check that shortcode templates exist in layouts/shortcodes/
  • Use hugo --disableKinds=shortcode temporarily to identify missing shortcodes

Common Mistakes with shortcode error

  1. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  2. Using return to exit a function early instead of wrapping a pure value in the monad
  3. Mixing let bindings with <- bindings in do notation, producing type errors

These mistakes appear frequently in real-world HUGO code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

How do I create a custom Hugo shortcode?

Create an HTML file in layouts/shortcodes/ with the shortcode name. Access inner content with .Inner and parameters with .Get "param". ||| Why does my shortcode render raw text? Shortcodes must use the correct delimiters. If you use backticks or escape characters, Hugo may not parse them. Check your markdown formatting. ||| Can I nest shortcodes in Hugo? Yes, but only with the percent-delimiter variant. Use the comment syntax to display shortcode examples literally.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro