Skip to content

fix/seo: Switch to per-page canonical URL - #2001

Merged
marcleblanc2 merged 1 commit into
mainfrom
marc/fix/per-page-canonical
Sep 18, 2026
Merged

marcleblanc2 merged 1 commit into
mainfrom
marc/fix/per-page-canonical

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Problem

  • Every page on the docs site tells search engines it is a duplicate of the landing page

  • Google reads that as "index the landing page, ignore the rest", which hurts how individual docs pages rank, and makes it harder for agents to find our doc content

Solution

  • generateMetadata sets alternates.canonical to /docs${post.url} so each page gets indexed

Verification

  • Compare production against the Vercel preview for this branch
PROD=https://sourcegraph.com/docs
PREVIEW=https://sourcegraph-docs-git-marc-fixper-pa-053b09-sourcegraph-f8c71130.vercel.app

for page in '' /cody /code-search /admin
do
  echo "== /docs$page"
  printf '  prod:    '; curl -s "$PROD$page"    | grep -o '<link rel="canonical"[^>]*>'
  printf '  preview: '; curl -s "$PREVIEW$page" | grep -o '<link rel="canonical"[^>]*>'
done

@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
sourcegraph-docs Ready Ready Preview Sep 18, 2026 4:58am UTC

Request Review

@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@marcleblanc2 marcleblanc2 changed the title fix/seo: Emit a per-page canonical URL fix/seo: Use a per-page canonical URL Sep 18, 2026
@marcleblanc2 marcleblanc2 changed the title fix/seo: Use a per-page canonical URL fix/seo: Switch to per-page canonical URL Sep 18, 2026
@marcleblanc2
marcleblanc2 marked this pull request as ready for review September 18, 2026 04:00
@marcleblanc2
marcleblanc2 requested review from a team and enriquegh September 18, 2026 04:00
Every docs page shipped <link rel=canonical href=https://sourcegraph.com/docs>,
so search engines treat all 500+ pages as duplicates of the landing page.
generateMetadata now sets alternates.canonical to the page's own path;
metadataBase in layout.tsx resolves it to an absolute URL.

Found by the docs site audit in
https://ampcode.com/threads/T-01a0ae50-f7f0-779c-aa66-3887c9953e33

Amp-Thread-ID: https://ampcode.com/threads/T-01a0aed2-5fbe-7768-85ea-1378bf98f9ff
Co-authored-by: Amp <amp@ampcode.com>
@marcleblanc2
marcleblanc2 force-pushed the marc/fix/per-page-canonical branch from a186f9e to ca00723 Compare September 18, 2026 04:56
@marcleblanc2
marcleblanc2 merged commit 85d32f0 into main Sep 18, 2026
6 checks passed
@marcleblanc2
marcleblanc2 deleted the marc/fix/per-page-canonical branch September 18, 2026 04:58
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.

2 participants