fix(seo): default sitemap + robots to canonical www host#129
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Google indexes only ~8 pages of gnars.com. Root cause is a canonical-host split in the code defaults:
NEXT_PUBLIC_SITE_URLis unsetsrc/app/[locale]/layout.tsx(metadataBase→ page canonicals)https://www.gnars.comsrc/lib/config.ts(BASE_URL)https://www.gnars.comsrc/app/robots.tshttps://gnars.com❌src/app/sitemap.xml/route.tshttps://gnars.com❌NEXT_PUBLIC_SITE_URLis unset in production, so the page canonicals resolve towwwwhile the sitemap emits 2,564non-wwwURLs.gnars.com307-redirects towww.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.tsandsitemap.xml/route.tsdefaults (andenv.example) to the canonicalhttps://www.gnars.com, matchingmetadataBaseandBASE_URL. Now sitemap / robots / canonical all agree. No behavior change whenNEXT_PUBLIC_SITE_URLis explicitly set.After merge / deploy
/sitemap.xmlserveswwwURLs.https://www.gnars.com/sitemap.xml(ideally on a Domain propertysc-domain:gnars.com, which captures www + non-www) and request indexing on key pages.🤖 Generated with Claude Code