Skip to content

Language resolution incorrect when calling shortcodes written as .md file #14098

@taoyouh

Description

@taoyouh

Summary

Given a multilingual shortcode defined as 2 files shortcode-md.en.md and shortcode-md.zh.md, the calling code {{% shortcode-md %}} always resolves to the shortcode-md.en.md even if the content language code is set to "zh". However if the short code is defined as .html files, the resolution works as expected.

Reproduce steps

Create an empty site as the getting started guide, and add/update the following files:

contents/posts/my-first-post.md:

+++
date = '2025-10-26T12:24:36+08:00'
title = 'My First Post'
+++

{{% shortcode-html %}}

{{% shortcode-md %}}

shortcode-html.en.html:

My HTML short code (en version). Current language: {{ .Site.Language.LanguageCode }}

shortcode-html.zh.html:

My HTML short code (zh version). Current language: {{ .Site.Language.LanguageCode }}

shortcode-md.en.md:

My MD short code (en version). Current language: {{ .Site.Language.LanguageCode }}

shortcode-md.zh.md:

My MD short code (zh version). Current language: {{ .Site.Language.LanguageCode }}

hugo.toml:

baseURL = 'https://example.org/'
languageCode = 'zh'
defaultContentLanguage = 'zh'
title = 'My New Hugo Site'
theme = 'ananke'

[languages.zh]
disabled = false
languageCode = 'zh'

[languages.en]
disabled = false
languageCode = 'en'

Behavior observed

The index page gives this rendering:

My HTML short code (zh version). Current language: zh
My MD short code (en version). Current language: zh

Expected behavior

The index page shall give this rendering:

My HTML short code (zh version). Current language: zh
My MD short code (zh version). Current language: zh

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.152.2-6abdacad3f3fe944ea42177844469139e81feda6+extended windows/amd64 BuildDate=2025-10-24T15:31:49Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions