Content adapters: shortcode not rendered unless preceded by text

I am trying content adapters with local data. But, shortcode in content do not works.

local data: /data/posts.json

_content.gotmpl:

{{ range .Site.Data.posts }}
  {{ $content := dict
    "mediaType" "text/markdown"
    "value" .content
  }}
  {{ $dates := dict
    "date" (time.AsTime .date)
  }}
  {{ $params := dict
    "tags" .tags
  }}
  {{ $page := dict
    "content" $content
    "dates" $dates
    "kind" "page"
    "params" $params
    "path" .path
    "title" .title
  }}
  {{ $.AddPage $page }}
{{ end }}

For example, twitter shortcode.

Case 1:

[
  {
    "date": "2024-05-28T20:25:56",
    "path": "2024/05/28202556",
    "title": "interesting!",
    "tags": ["Hugo"],
    "content": "Interesting!{{< twitter user=\"gohugoiov2\" id=\"1792275723438133434\" >}}"
  }
]

It works fine.

But, case 2:

[
  {
    "date": "2024-05-28T20:25:56",
    "path": "2024/05/28202556",
    "title": "interesting!",
    "tags": ["Hugo"],
    "content": "{{< twitter user=\"gohugoiov2\" id=\"1792275723438133434\" >}}"
  }
]

No displays. It do not works.

It appears to depend on whether there is any text (“Interesting!” in the example above) before the shortcode.

Anybody has ideas?

This is a bug. See:
https://github.com/gohugoio/hugo/issues/12544

Currently the shortcode call must be preceded by a character.

1 Like

Thanks for your reply. I understand.

1 Like

This is fixed in the next release.

1 Like

Thank you so much!! I appreciate it once again.

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