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
-
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!
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.
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 Variable | Value | |
---|---|---|
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 |
| |
NextPage | Using only defined shortcodes | |
PrevPage | Date + Time (behind UTC) | |
NextInSection | Using only defined shortcodes | |
PrevInSection | None |
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 Variable | Value |
---|---|
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" |