Skip to content

fix(seo): default sitemap + robots to canonical www host#129

Merged
sktbrd merged 1 commit into
mainfrom
fix/canonical-www-sitemap
Jul 8, 2026
Merged

fix(seo): default sitemap + robots to canonical www host#129
sktbrd merged 1 commit into
mainfrom
fix/canonical-www-sitemap

Conversation

@sktbrd

@sktbrd sktbrd commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Problem

Google indexes only ~8 pages of gnars.com. Root cause is a canonical-host split in the code defaults:

Source Default when NEXT_PUBLIC_SITE_URL is unset
src/app/[locale]/layout.tsx (metadataBase → page canonicals) https://www.gnars.com
src/lib/config.ts (BASE_URL) https://www.gnars.com
src/app/robots.ts https://gnars.com
src/app/sitemap.xml/route.ts https://gnars.com

NEXT_PUBLIC_SITE_URL is unset in production, so the page canonicals resolve to www while the sitemap emits 2,564 non-www URLs. gnars.com 307-redirects to www.gnars.com, so every sitemap entry is a redirect that disagrees with the canonical — Google dropped almost the entire site. This lines up with the Search Console cliff: ~1,400 impressions/mo (Jan–Apr) → ~0 from May onward.

Fix

Align robots.ts and sitemap.xml/route.ts defaults (and env.example) to the canonical https://www.gnars.com, matching metadataBase and BASE_URL. Now sitemap / robots / canonical all agree. No behavior change when NEXT_PUBLIC_SITE_URL is explicitly set.

After merge / deploy

  1. Redeploy so /sitemap.xml serves www URLs.
  2. In Search Console, submit https://www.gnars.com/sitemap.xml (ideally on a Domain property sc-domain:gnars.com, which captures www + non-www) and request indexing on key pages.
  3. Recommended (infra, not this PR): make the apex→www redirect permanent (308) — it's currently a 307 (temporary).

🤖 Generated with Claude Code

sitemap.xml and robots.ts defaulted NEXT_PUBLIC_SITE_URL to
https://gnars.com while metadataBase (layout) and BASE_URL (config)
default to https://www.gnars.com. With the env var unset in prod, the
sitemap emitted 2,564 non-www URLs that all 307-redirect to www, and the
page canonicals point to www — so Google dropped almost the whole site
(down to ~8 indexed pages). Align both defaults (and env.example) to the
canonical www host so sitemap/robots/canonical agree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
gnars-shadcn Ignored Ignored Jul 8, 2026 9:40pm
hackertestdao Ignored Ignored Jul 8, 2026 9:40pm

@sktbrd
sktbrd merged commit 1878945 into main Jul 8, 2026
4 checks passed
@sktbrd
sktbrd deleted the fix/canonical-www-sitemap branch July 8, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant