Hugo: How to escape shortcode in markdown

Hugo: How to escape shortcode in markdown to display as literal text.

Problem with shortcode like text in Hugo markdown

In Hugo markdown, if you have some text wrapped by curly brackets likes following:

Today: {{%m%d%y}}

You will receive an error similar to the following:

Error: Error building site: "": failed to extract shortcode: template for shortcode "m" not found

This is due to Hugo treat {{%m%d%d}} as its shortcode .

A shortcode is a simple snippet inside a content file that Hugo will render using a predefined template. In your content files, a shortcode can be called by calling {{% shortcodename parameters %}}.

Solution on how to escape shortcode in Hugo markdown

Solution 1: Add space between {{ (curly bracket) and %.

Today: {{ %m%d%y }}

Solution 2: Escape % with unicode in HTML

If you don’t want extra space between {{ and %, you can escape % with %. Example:

Today: {{%m%d%y}}

This trick is being used by this page.

See also:


A1 - Block / Hide iOS Apps

Hide Apps from Home Screen, App Library and Lock Apps to protect your privacy even further (requires iOS 16).

DNS Firewall for iOS and Mac OS

Encrypted your DNS to protect your privacy and firewall to block phishing, malicious domains, block ads in all browsers and apps