.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 Oct 09, 2018 14:48 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/"
RSSLink ""
Data
KeyTypeValue
Pageshugolib.Pages
NextPageUsing only defined shortcodes
PrevPageDate + Time (behind UTC)
NextInSectionUsing only defined shortcodes
PrevInSectionNone

Page Params (Debug)

KeyTypeValue
datetime.Time 2017-11-02 12:48:00 -0400 -0400
draftbool false
iscjklanguagebool false
lastmodtime.Time 2017-11-02 12:49:28 -0400 -0400
publishdatetime.Time 2017-11-02 12:48:00 -0400 -0400
titlestring "Using undefined shortcodes"

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.50-DEV (commit d5d50e2f, using Chroma commit d5ca12b) .

[Back to Hugo Sandbox home]