Hugo: How to escape shortcode in markdown
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: "foo.md:36:25": 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.
Solution 3: Use /* */
comment
Use /* */
to quote the comment shortcode.
{{< myshortcode param1="value1" param2="value2" >}}
Related pages:
- Demystifying Hugo Shortcodes: Your Ultimate Guide
- Add comments to Static blog like Hugo, Jekyll with Isso
- Tips on Hugo SEO
- Custom hugo RSS template
- Hugo troubleshooting: execute of template failed: can't give argument to non-function
- Add git commit date as last update date in hugo page
References
OmniLock - Block / Hide App on iOS
Block distractive apps from appearing on the Home Screen and App Library, enhance your focus and reduce screen time.
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