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:45 +08:00
parent 071da45a43
commit a772abb406
2 changed files with 2 additions and 2 deletions

View File

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

View File

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