Skip to content

Bug: Home page OG/Twitter image broken for zh-CN locale (missing zh-CN→zh filename mapping) #243

Description

@evan188199-tech

Bug

The home page generates a broken OpenGraph / Twitter card image for the zh-CN locale, because page.tsx interpolates the raw locale into the filename (default-og-image_zh-CN.jpg) while the actual file is named default-og-image_zh.jpg.

Root cause

app/[locale]/(app)/page.tsx (lines 34, 44):

url: `${getServerUrl()}/images/default-og-image_${locale}.jpg`,

For locale === "zh-CN" this produces /images/default-og-image_zh-CN.jpg, which does not exist (only default-og-image_zh.jpg is shipped).

The codebase already knows about this mismatch and applies a zh-CNzh mapping in 5 other places:

  • app/[locale]/layout.tsx:157locale === "zh-CN" ? "zh" : locale
  • src/components/seo/SEOHead.tsx:49,183 — same mapping
  • src/shared/lib/structured-data.ts:269 — same mapping

… but misses it in:

  • app/[locale]/(app)/page.tsx:34,44 (home page metadata)
  • src/shared/lib/structured-data.ts:219,250 (structured data image)

Impact

When a Chinese-locale home page URL is shared on social media (Twitter, Facebook, Slack, etc.), the OG/Twitter card shows a broken image. The other Chinese pages work fine (they use the mapped path), so it's specifically the home page that's affected.

Fix

Apply the same zh-CNzh mapping that the rest of the codebase uses:

const ogImageLocale = locale === "zh-CN" ? "zh" : locale;
// ...
url: `${getServerUrl()}/images/default-og-image_${ogImageLocale}.jpg`,

I have a PR ready (fixing page.tsx + the two structured-data.ts misses).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions