Error using shortcodes in template block redefinition

If I use a shortcode inside a block redefinition, I get the below error.

Am I doing something wrong?

$ hugo --verbose
INFO 2019/12/08 07:17:19 No translation bundle found for default language "en"
INFO 2019/12/08 07:17:19 Translation func for language en not found, use default.
INFO 2019/12/08 07:17:19 i18n not initialized; if you need string translations, check that you have a bundle in /i18n that matches the site language or the default language.
Total in 17 ms
Error: add site dependencies: load resources: loading templates: "/home/mhh/sites/scgit/layouts/index.html:2:1": parse failed: template: index.html:2: unexpected "<" in command

The error happens in both v0.60.1 as well as v0.58.3.

The code can be found in this public repository.

If you don’t want to use the repo, you can reproduce by:

  1. Create a new site
  2. Add a file layouts/_default/baseof.html with the following content:
    <html><head></head>
    <body>
        {{block "main" .}}
        <h1>Hello</h1>
        {{end}}
    </body></html>
    
  3. Add file layouts/index.html with the following content:
    {{define "main"}}
    {{< gist user 12345 >}}
    {{end}}
    

Hi there,

Shortcodes are meant to be used in your content files, not template/layout files.

From the docs: https://gohugo.io/content-management/shortcodes/

A shortcode is a simple snippet inside a content file that Hugo will render using a predefined template. Note that shortcodes will not work in template files. If you need the type of drop-in functionality that shortcodes provide but in a template, you most likely want a partial template instead.

Ah. That was what I was missing. Thank you.

Must say I find the distinction somewhat questionable, but okay.

Thanks again.

If it helps: you can use a partial in a template file roughly the same way you can use a shortcode in a content file.

It does.

Though losing .Inner is a bummer.