Malformed shortcode triggers warning instead of error?

When Hugo detects a malformed shortcode, say {{< tweet 1234 >}, it will throw an error, continue with the build, and render the shortcode as:

<p>{{&lt; tweet 1234 &gt;}</p>

That HTML output is exactly what I’d expect. However, it would be great if there was a config option that a malformed shortcode should trigger a warning instead of an error.

This would allow automated build systems (Deploybot in my case) to continue building/deploying the site. Currently, Deploybot exits when it sees the error, even though Hugo does render the page containing the bad shortcode and completes the rest of the build.

I should add that my site has some non-technical editors with permission to add Markdown files, but they don’t have access to Deploybot. So they don’t get notifications that the build failed, all they know is that they added a post to the repo and it didn’t show up on the site.

We have a discussion about this from time to time and it is

  1. Very hard to create a general rule about severity for these kinds of issues. It is definitively broken, but is it “broken enough”?
  2. We’re (most likely) not adding flags/complexity, so unless you can answer the “broken enough?” question on behalf of me and the rest of the Huogo community, I suggest you either 1) Fix your site or 2) Create a shell script wrapper around hogo that swallows the exit code.

Thanks for responding so quickly! I guess it depends on how much you care about sites where content authors don’t have access to the build process. If it’s not something you care about, then I’m definitely an edge case.

But if accommodating sites with content-only “users” is part of the road map, then I’d recommend a rule of thumb like:

Problems with the content of a page that do not prevent the page from being built should be warnings.

FWIW, my background is building CMS-driven sites for large news publishers. So I’ve spent a lot of time thinking about editorial UX.

That statements breaks down fast. To me, a site with heavy shortcode usage that cannot render shortcodes is a broken site.

What we could consider is to add some kind of configurable ERROR count threshold to the “exit -1” rule.

But you would have to create a GitHub issue for me to track it.

I totally agree that the site is broken if it cannot render correctly formed shortcodes. But if the site cannot render a shortcode like {{< tweet 1234 >} with a missing curly brace, then the site itself isn’t broken. I probably should have said as my rule of thumb:

Problems emanating from a file in the content directory that do not prevent the page from being built should be warnings.

So in the case of that missing curly brace, Hugo would render <p>{{&lt; tweet 1234 &gt;}</p> (as it does now) and continue with a warning.