fix(seo): URL-encode tag in canonical link

Tag pages emitted <link rel="canonical" href="...tag/Foo Bar/">
with literal spaces. Wrap with encodeURIComponent so the canonical
matches the encoded URL in the sitemap.
This commit is contained in:
2026-04-28 18:22:47 +08:00
parent af832748ff
commit 3a326b7f84
2 changed files with 2 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ const page = {
}, },
}; };
const canonical = `${site.url}/tag/${tag}/`; const canonical = `${site.url}/tag/${encodeURIComponent(tag)}/`;
--- ---
<Layout <Layout
title={`Tagged: ${tag} — ${site.name}`} title={`Tagged: ${tag} — ${site.name}`}

View File

@@ -45,7 +45,7 @@ const page = {
}, },
}; };
const canonical = `${site.url}/tag/${tag}/page/${currentPage}/`; const canonical = `${site.url}/tag/${encodeURIComponent(tag)}/page/${currentPage}/`;
--- ---
<Layout <Layout
title={`Tagged: ${tag} — Page ${currentPage} — ${site.name}`} title={`Tagged: ${tag} — Page ${currentPage} — ${site.name}`}