← Writing

Cloudflare Pages 308-redirects your no-slash URLs — make canonicals match

Directory-format builds on Cloudflare Pages only serve the trailing-slash URL. If your canonicals and sitemap use the no-slash form, Google sees every page as a redirect.

Google Search Console flagged most of my pages as “Page with redirect.” The cause: my Astro build outputs directory-shaped files (/work/index.html), and Cloudflare Pages serves those only at /work/ — requesting /work gets a 308 redirect. My canonicals and sitemap both used the no-slash form.

So I was submitting redirects to Google, and every page’s canonical tag pointed at a redirect.

curl -sI https://example.com/work | grep -i location
# location: https://example.com/work/

The fix is to stop fighting the platform: canonical tags and sitemap URLs must use the trailing-slash form — the only one that returns 200. If you’re on Astro with @astrojs/sitemap, don’t strip slashes in serialize(), and build your canonical with the slash.

← All writing Book a call →
Book a call → WhatsApp