How to reuse the shortcode block?

Hi, I’m writing posts in multiple languages, I would like to reuse some shortcode block cross posts writing in different languages. Is there any way to do that?

For example:

<!-- foobar/index.md -->
{{< myshortcode key="value" >}}
SHORTCODE CONTENT
{{< /myshortcode >}}
<!-- foobar/index.zh-cn.md -->
{{< myshortcode key="value" >}}
SHORTCODE CONTENT
{{< /myshortcode >}}

I want to resue the shortcode block:

{{< myshortcode key="value" >}}
SHORTCODE CONTENT
{{< /myshortcode >}}

Now, I’m doing that by creating a new shortcode myshortcode-content:

SHORTCODE CONTENT

And then embedded it as follows:

{{< myshortcode key="value" >}}
{{< myshortcode-content >}}
{{< /myshortcode >}}

Is there a better way to do that? Thanks.

You could put the reusable stuff into a headless bundle, and include those in the posts using a shortcode.

1 Like

Thanks for your reply, but this way does not solve the problem in multilingual site, since I’ll have to define the headless pages in multiple languages(headless/foo.md, headless/foo.zh-cn.md), it isn’t reusable in this case.

Sorry, then I probably don’t understand the exact usecase.

1 Like