.Page.RenderString throws error when rendering an escaped shortcode call

this was originally targeted at 0.102, but it seems like it didn’t make the cut.

what is current guidance on how affected users should proceed?

@Wolfspyre There are several ways to include and render a snippet of code. Can you provide an example of what you are trying to achieve?

well, that issue is the problem i’m experiencing:

i discovered the change in behavior in the theme I am using, and opened a question here:

which resulted in that issue being created…

I’m not sure what the right way forward is… got any suggestions?

The problem with “that” issue (#10058) is that it doesn’t yet provide any meaningful detail. Thanks for the link to the original discussion; now we have some context.

This fails with v0.100.0 and later

{{< sc >}}
{{</* foo */>}}
{{< /sc >}}


{{ .Inner | .Page.RenderString }}

failed to render shortcode “sc”: failed to process shortcode: “/home/user/project/layouts/shortcodes/sc.html:1:17”: execute of template failed at <.Page.RenderString>: error calling RenderString: “/home/user/project/content/_index.md:2:1”: failed to extract shortcode: template for shortcode “foo” not found


{{< sc >}}
{{</*/* foo */*/>}}
{{< /sc >}}

This works as expected

{{% sc %}}
{{</* foo */>}}
{{% /sc %}}


{{ .Inner }}

  1. See this discussion comment. ↩︎

i’m having a

It comes in PINTS?!

moment here :slight_smile:

I didn’t know about
{{% sc %}}

as an alternative declaration style. that’s brilliant.

I wonder… do you know if the inverse works as well?

{{< sc >}}

{{% sub-sc %}}
{{% /sub-sc %}}

{{< /sc >}}

To clarify, {{% sc %}} is not an alternative declaration style; it is not interchangeable with {{< sc >}}. And, in some cases, the shortcode itself must be written differently depending on the notation used in the call.

Sure, but it depends on what you are trying to accomplish. Please experiment.


To clarify, {{% sc %}} is not an alternative declaration style; it is not interchangeable with {{< sc >}} .

Hm… The only instruction/docs I found were Here[1] on the hugo docsite. Are you aware of any more in-depth docs on the distinction between the two delimiters?

  1. https://gohugo.io/content-management/shortcodes/ “shortcodes docs” ↩︎

The key points from the page you reference…


Shortcodes using the % as the outer-most delimiter will now be fully rendered when sent to the content renderer. They can be part of the generated table of contents, footnotes, etc.


The < character indicates that the shortcode’s inner content does not need further rendering. Often shortcodes without markdown include internal HTML

More explanation and examples here:


Yeah… I saw those, I was more wondering if you were aware of a more in-depth explanation, as… well… clearly you know… small differences can have a vast impact… so I was looking for more than a oneline explanation of the change in behavior…

which you posted… (thank you for the link!!!) It might be nice to reference that discourse link in the hugo docs someplace to help peeps like me find a clue-by-four. :wink: Your writeup was really sincerely helpful.

Thank you for taking the time out of your day to help some random human on the internet.

I appreciate you. The world needs more good humans who value helping others.
I hope your day is awesome. You certainly deserve it.


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.