.Kind (page): .Type (bugs) / .Layout ()
Bundle: n/a (regular page)
[ categories | projects | tags | search ]
Hugo Sandbox

This is an unofficial Hugo sandbox site to try to replicate possible bugs in hugo.

It is updated automatically after each commit to the hugo-sandbox repo. It was last updated on Jan 20, 2022 13:08 UTC.


This page was created/modified in commit c99682c "Add dates" on 2017-11-02.
Markdown source of this page

Using undefined shortcodes


Description/Summary

Using an undefined shortcode below! To see the issue, remove the x from {x{ below, and run hugo server. {x{< img src="foo.png" >}} Issue The website will generate fine, but with a silent error on the terminal: ERROR 2017/11/02 10:37:54 Unable to locate template for shortcode "img" in page "posts/src-block-hugo-shortcoded-undefined.md" The hugo server run server will keep on living, and generating the pages almost correctly, while just balking on shortcode expansions!


Content

Using an undefined shortcode below!

To see the issue, remove the x from {x{ below, and run hugo server.

{x{< img src="foo.png" >}}

Issue

With special shortcode comment chars

Now, as an invalid shortcode img was used above, none of the following short codes seem to get processed. So {{</* .. */>}} appears as it is below.

{{< figure src="/images/org-mode-unicorn-logo.png" title="Org Mode + Hugo Rock!" >}}

Without special shortcode comment chars

Now, as an invalid shortcode img was used above, none of the following short codes seem to get processed. So even {{< .. >}} appears as it is below.

Org Mode + Hugo Rock!

So, what should be fixed?

I think, that if an invalid shortcode is found, Hugo should simply abort the hugo server, so that a user doesn’t think that things are good. This issue left me confused for a while as to why the shortcodes with comment chars were behaving differently.

It’s good that hugo aborts right away on finding this undefined shortcode img, but hugo server keeps on living.


Page (Debug)

Page VariableValue
Name "Using undefined shortcodes"
Title "Using undefined shortcodes"
ResourceType "page"
Kind "page"
Section "bugs"
Draft false
Type "bugs"
Layout ""
Permalink "https://hugo-sandbox.netlify.com/bugs/src-block-hugo-shortcodes-undefined/"
RelPermalink "/bugs/src-block-hugo-shortcodes-undefined/"
Data
page.Data{} (type:page.Data)
NextPageUsing only defined shortcodes
PrevPageDate + Time (behind UTC)
NextInSectionUsing only defined shortcodes
PrevInSectionNone

Page Params (Debug)

maps.Params{"date":time.Date(2017, time.November, 2, 12, 48, 0, 0, time.Location("")), "draft":false, "iscjklanguage":false, "lastmod":time.Date(2017, time.November, 2, 12, 49, 28, 0, time.Location("")), "publishdate":time.Date(2017, time.November, 2, 12, 48, 0, 0, time.Location("")), "title":"Using undefined shortcodes"} (type:maps.Params)

File Object (Debug)

FileInfo VariableValue
UniqueID "c2009c64745a789f734504389ca53d89"
BaseFileName "src-block-hugo-shortcodes-undefined"
TranslationBaseName "src-block-hugo-shortcodes-undefined"
Lang "en"
Section "bugs"
LogicalName "src-block-hugo-shortcodes-undefined.md"
Dir "bugs/"
Ext "md"
Path "bugs/src-block-hugo-shortcodes-undefined.md"

This site is generated using the ox-hugo package for Emacs/Org-mode + hugo-bare-min-theme + Hugo 0.92.0 (commit b3549403) .

[Back to Hugo Sandbox home]