diff --git a/client/public/index.html b/client/public/index.html
index d4f45ed2b1e9..82f3d5e47791 100644
--- a/client/public/index.html
+++ b/client/public/index.html
@@ -52,12 +52,21 @@
-->
-
+
+
+
+
+
+
+
diff --git a/ssr/render.ts b/ssr/render.ts
index 2a9be7209862..05a7aaa2fa24 100644
--- a/ssr/render.ts
+++ b/ssr/render.ts
@@ -233,10 +233,16 @@ export default function render(
)
.join("");
+ // Open Graph protocol expects `language_TERRITORY` format.
+ const ogLocale = (locale || (doc && doc.locale) || DEFAULT_LOCALE).replace(
+ "-",
+ "_"
+ );
+
const og = new Map([
["title", escapedPageTitle],
["url", canonicalURL],
- ["locale", locale || (doc && doc.locale) || "en-US"],
+ ["locale", ogLocale],
]);
if (pageDescription) {
diff --git a/testing/tests/index.test.ts b/testing/tests/index.test.ts
index ac0708f8e318..b02165609c66 100644
--- a/testing/tests/index.test.ts
+++ b/testing/tests/index.test.ts
@@ -239,7 +239,7 @@ test("content built zh-CN page for hreflang tag and copying image testing", () =
expect($('link[rel="alternate"][hreflang="fr"]')).toHaveLength(1);
expect($('link[rel="alternate"][hreflang="zh"]')).toHaveLength(1);
expect($('link[rel="alternate"][hreflang="zh-Hant"]')).toHaveLength(1);
- expect($('meta[property="og:locale"]').attr("content")).toBe("zh-CN");
+ expect($('meta[property="og:locale"]').attr("content")).toBe("zh_CN");
expect($('meta[property="og:title"]').attr("content")).toBe(
": 测试网页 | MDN"
);
@@ -273,7 +273,7 @@ test("content built zh-TW page with en-US fallback image", () => {
expect($('link[rel="alternate"][hreflang="fr"]')).toHaveLength(1);
expect($('link[rel="alternate"][hreflang="zh"]')).toHaveLength(1);
expect($('link[rel="alternate"][hreflang="zh-Hant"]')).toHaveLength(1);
- expect($('meta[property="og:locale"]').attr("content")).toBe("zh-TW");
+ expect($('meta[property="og:locale"]').attr("content")).toBe("zh_TW");
expect($('meta[property="og:title"]').attr("content")).toBe(
": 測試網頁 | MDN"
);
@@ -1165,7 +1165,7 @@ test("404 page", () => {
expect($("title").text()).toContain("Page not found");
expect($("h1").text()).toContain("Page not found");
expect($('meta[name="robots"]').attr("content")).toBe("noindex, nofollow");
- expect($('meta[property="og:locale"]').attr("content")).toBe("en-US");
+ expect($('meta[property="og:locale"]').attr("content")).toBe("en_US");
});
test("plus page", () => {