Skip to content

Commit cef7ca8

Browse files
committed
fix: canonical URLs keep the trailing slash
Cloudflare Pages 308-redirects /blog/adr47 to /blog/adr47/, and the sitemap emits the slashed form, so stripping the slash pointed each canonical at a URL that redirects to the canonical.
1 parent 72fa2bf commit cef7ca8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/layouts/BaseLayout.astro

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ const {
2121
personSchema = false,
2222
} = Astro.props;
2323
24-
const canonical = new URL(Astro.url.pathname, Astro.site).href.replace(/(.)\/$/, '$1');
24+
// Keep the trailing slash: Cloudflare Pages 308-redirects /blog/adr47 to
25+
// /blog/adr47/, and the sitemap emits the slashed form. Stripping it here would
26+
// point the canonical at a URL that redirects to the canonical.
27+
const canonical = new URL(Astro.url.pathname, Astro.site).href;
2528
const ogImageUrl = new URL(ogImage, Astro.site).href;
2629
2730
const fontHref =

0 commit comments

Comments
 (0)