promptunit

Canonical Conflict Doctor: Why Google Picked a Different URL

Search Console says 'Duplicate, Google chose different canonical than user' and your page won't rank? This prompt finds every mixed signal that confuses Google (tags, redirects, links, sitemaps, JavaScript and error pages) and lines them all up so Google picks the URL you want.

Works in ChatGPTClaudeGemini557 words6 inputs to fillSEO-034

Example input

This is exactly what we gave the model. You replace it with your own details.

- Website: https://www.example.com (sneaker store)
- Platform: Next.js storefront with a headless commerce backend
- Affected URLs and the canonical Google chose instead (from URL Inspection):
/products/air-runner-white/ -> Google chose /products/air-runner-white/?color=white
/products/air-runner-black/ -> Google chose /products/air-runner/
/collections/running/page/2/ -> Google chose /collections/running/
/products/court-classic-red/ -> Google chose https://sneaker-deals.example/court-classic-red (another website)
- Search Console count for 'Duplicate, Google chose different canonical than user': 1,140
- How canonicals are set: Raw HTML has a canonical from the server template; a React component sets a canonical again after load
- Optional: HTML head of 2 affected pages (raw and rendered):
/products/air-runner-black/ raw HTML: <link rel="canonical" href="https://www.example.com/products/air-runner/">
rendered HTML: <link rel="canonical" href="https://www.example.com/products/air-runner/"> and <link rel="canonical" href="https://www.example.com/products/air-runner-black/">
/collections/running/page/2/ raw and rendered: <link rel="canonical" href="https://www.example.com/collections/running/">
The XML sitemap lists /products/air-runner-black/ and /products/air-runner-white/?color=white.

Real output

Pasted straight from the model. We did not fix a word.

Fixing "Google chose different canonical" on example.com

Missing details: my best guesses

A few details are missing. Here is my best guess for each one. I use these guesses in the rest of the answer, so tell me if any of them is wrong.

  1. What canonical tags do /products/air-runner-white/ and /products/air-runner-white/?color=white have? Guess: they use the same product template as the black page. The raw HTML points to /products/air-runner/, and the React component adds a second tag built from the current browser URL. That means the ?color=white version gets a canonical that keeps ?color=white in it.
  2. Are the color pages really different, and what is /products/air-runner/? Guess: each color has its own photos, SKU, stock and price, and people search by color ("air runner black"). /products/air-runner/ is the model page, and it shows the default color (black), so it is almost a copy of /products/air-runner-black/.
  3. Where do your internal links point? Guess: collection grids and breadcrumbs link to /products/air-runner/, and the color swatches link to ?color= URLs.
  4. What is sneaker-deals.example? Guess: it isn't yours. It's a deal or affiliate site that copies your product text and photos, maybe from a product feed.
  5. Do you use bot protection, and which Next.js router do you use? Guess: yes, a bot-challenge rule is on (Cloudflare, Vercel Firewall or another WAF). Guess: App Router. I also include Pages Router code.

I also assumed a few smaller things without asking. Guess: the site is HTTPS only, and http and non-www URLs 301 to https://www.. Guess: there is no hreflang (one market). Guess: all URLs are lowercase with a trailing slash. Guess: collections have no "view all" page.


1. Signal table

"mine" = points to your URL. "other" = points somewhere else.

URLCanonical tagSitemapInternal linksRedirectsRaw vs renderedGoogle's choiceConflict found
/products/air-runner-white/Guess: raw → /products/air-runner/ (other). React adds self (mine)Lists ?color=white version (other)Guess: swatches → ?color=white (other)None. ?color=white is not redirected to the clean URL (other)Guess: 1 tag raw, 2 different tags rendered/products/air-runner-white/?color=whiteYes. The tags cancel each other out. Then the sitemap and links decide, and both point to the parameter URL
/products/air-runner-black/Raw → /products/air-runner/ (other). Rendered: /products/air-runner/ (other) + self (mine)Lists this URL (mine)Guess: grids and breadcrumbs → /products/air-runner/ (other)NoneMismatch: 1 tag raw, 2 different tags rendered/products/air-runner/Yes. Your own raw HTML names the URL Google chose. The shorter URL and near-identical content also favor it
/collections/running/page/2/→ /collections/running/ (other)Guess: not listed (neutral)Guess: "2 / Next" links → page 2 (mine)NoneMatch (both → page 1)/collections/running/No conflict. Google did what your tag said. The tag itself is wrong
/products/court-classic-red/Guess: self in raw and rendered (mine), maybe as 2 identical tagsGuess: listed (mine)Guess: → your URL (mine)NoneGuess: matchsneaker-deals.example/court-classic-redGuess: your signals agree. The problem is what Googlebot sees, or a copy on another site

Other signals from step 1:

  • HTTPS: fine on all four URLs (guess). Not a cause.
  • hreflang: none (guess). Not a cause.
  • Parameters: ?color= creates a duplicate of the white page, and your sitemap promotes that duplicate. This is the main cause for white.
  • URL length: when the strong signals cancel out, Google prefers the shorter, cleaner URL. That helps /products/air-runner/ beat the black page. It doesn't explain white: Google picked the longer URL there because the sitemap and links pointed to it.

Two quick checks in URL Inspection (look at "User-declared canonical"):

  • Black page: it probably shows /products/air-runner-black/. That means Google took your JavaScript tag as your choice, then overruled it with the raw tag and the other signals.
  • Page 2: it will most likely show /collections/running/. If so, this URL is in the "Alternate page with proper canonical tag" bucket, not in your 1,140. It's still a bug, so fix it anyway.

2. Diagnosis by group

Group A: color variant product pages (air-runner-white, air-runner-black)

These are probably most of the 1,140 (guess), because the bug is in the product template, so it repeats on every product.

  • Main cause: two systems set the canonical, and they disagree. The server template says "the parent model page". The React component says "this URL", built from the browser URL with the query string included. So the rendered HTML has two different canonical tags. When a page has two different canonicals, Google can't trust either one, so it falls back on weaker signals: the sitemap, internal links and URL length.
  • This is why each page got a different winner:
    • Black → /products/air-runner/: the raw tag, internal links (guess), the shorter URL and almost the same content all point there.
    • White → ?color=white: the sitemap and swatch links (guess) point there.
  • Decision: your color URLs should be canonical. This is based on guess 2: each color has unique photos, SKU, stock and search demand. Google isn't "wrong" here. It did what your mixed signals allowed. Fix the signals; don't fight Google.
    • /products/air-runner-white/: yours should be canonical. The ?color=white URL adds nothing.
    • /products/air-runner-black/: yours should be canonical, but only once /products/air-runner/ stops being a copy of it. Today the two pages are basically the same, so it's reasonable for Google to merge them.
    • When Google is right instead: if your color pages differ only by swatch and photos (same text, nobody searches by color), Google is right. In that case, make /products/air-runner/ the canonical for all colors, white included, and point every signal there. Pick one system and use it everywhere. Running half of each is what caused this.

Group B: paginated collection pages

  • Main cause: the collection template points page 2, 3 and so on to page 1. Raw and rendered HTML match, so Google simply obeyed. As a result, products that only appear on page 2+ lose their crawl path from an indexed page.
  • Decision: Google's choice is not better. Page 2 lists different products, and you have no view-all page (guess). So page 2 should point to itself.

Group C: another domain (court-classic-red)

  • Your on-page signals probably all point to you (guess). When Google still picks another domain, it usually sees a better or more reachable copy elsewhere. Likely causes for your setup, most likely first:
    1. Googlebot gets a bot-challenge page (guess 5). Every challenged URL looks like the same thin page, while sneaker-deals.example serves your full text.
    2. Googlebot got a 200 "unavailable" shell. For example, the headless backend timed out during the server render, or the product sold out and the template showed only an "unavailable" message. All such pages look the same, so Google treats them as duplicates.
    3. A scraper or affiliate copy of your text and photos, with no canonical back to you (guess 4).
  • Decision: your URL must be canonical. Google's choice is clearly worse for you, because another site gets your traffic.

3. Ordered fix list with code

Order matters. Ship Fix 2 before the redirect in Fix 3. If you don't, the black page's old canonical (→ /products/air-runner/) plus a new redirect (/products/air-runner/ → black) creates a loop.

Fix 1: Make sure Googlebot sees the real page (do this first; it can affect the whole site)

  1. Run URL Inspection on /products/court-classic-red/, then Test live URL → View tested page. Look at the screenshot and the HTML. Do you see the real product? Or do you see "Verify you are human", "Access denied", "Just a moment..." or "Product unavailable"?
  2. In your CDN or server logs, find requests from verified Googlebot (reverse DNS ends in googlebot.com or google.com) to /products/ URLs. Look for 403, 429, 503 or challenge responses.
  3. In your bot or WAF rule, add an allow or skip for verified search engine bots. Cloudflare and Vercel Firewall both have a "verified bots" option. Don't test this with curl -A Googlebot, because WAFs check the IP address, not the user agent.

Fix 2: One canonical per page, set on the server, never changed by JavaScript

Build every canonical in one function, and use that same function in the page head, the sitemap and your links.

// lib/canonical.ts (the ONLY place canonical URLs are built)
export const SITE = 'https://www.example.com';

/** Absolute, lowercase, trailing slash, no query string or hash */
export function canonicalUrl(path: string): string {
  let p = path.split(/[?#]/)[0].toLowerCase();
  if (!p.startsWith('/')) p = '/' + p;
  if (!p.endsWith('/')) p += '/';
  return SITE + p;
}

App Router (product page):

// app/products/[handle]/page.tsx
import type { Metadata } from 'next';
import { getProduct } from '@/lib/commerce'; // wrap in React cache() so it runs once per request
import { canonicalUrl } from '@/lib/canonical';

type Props = { params: Promise<{ handle: string }> };

export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const { handle } = await params;
  const product = await getProduct(handle);
  if (!product) return {};
  return {
    // Each color page is its own canonical. Never use product.parent.handle here.
    alternates: { canonical: canonicalUrl(`/products/${product.handle}/`) },
  };
}

Pages Router (if that's what you use):

// pages/products/[handle].tsx
import Head from 'next/head';

<Head>
  <link rel="canonical" href={canonicalUrl(`/products/${product.handle}/`)} key="canonical" />
</Head>
// Also make sure _document.tsx and _app.tsx set no canonical.

Delete the second canonical. Find it with grep -rn "canonical" app pages components src lib. It usually looks like one of these:

// DELETE patterns like these:
useEffect(() => {
  const link = document.createElement('link');
  link.rel = 'canonical';
  link.href = window.location.href;           // keeps ?color=white
  document.head.appendChild(link);
}, []);

<link rel="canonical" href={SITE + router.asPath} />   // inside any component
<DefaultSeo canonical={SITE + router.asPath} />        // next-seo in _app

Note: in React 19 / Next 15, a <link rel="canonical"> rendered inside any component gets moved into <head>. It adds a second tag. It doesn't replace the first one.

Fix 3: Apply one variant rule (color pages point to themselves)

  • The canonical function in Fix 2 already uses the color page's own handle. Remove the parent-handle logic from the server template.
  • Stop /products/air-runner/ from being a copy of the black page. Pick one:
    • A. Make it a real model hub (my pick; guess). Use a title like "Air Runner, all colors", a grid linking to every color page, its own intro text, and a self-canonical. It can rank for "air runner", while the color pages rank for "air runner black".
    • B. 301 it to the default color, if you don't want a hub:
// app/products/[handle]/page.tsx, inside the page component (field names are placeholders)
import { permanentRedirect } from 'next/navigation';

if (product.isModel && !product.hasHubContent) {
  permanentRedirect(`/products/${product.defaultVariant.handle}/`); // 308, which Google treats like a 301
}

Fix 4: Remove the ?color= duplicates and the page-1 duplicate

?color=white on /products/air-runner-white/ adds nothing, so redirect it. Don't noindex it. A redirect is a strong signal, while noindex mixed with canonicals sends mixed signals.

// middleware.ts
import { NextResponse, type NextRequest } from 'next/server';

export function middleware(req: NextRequest) {
  const url = req.nextUrl.clone();
  let redirect = false;

  // 1. Redundant color param: /products/air-runner-white/?color=white → /products/air-runner-white/
  const color = url.searchParams.get('color')?.toLowerCase();
  if (color && url.pathname.replace(/\/$/, '').endsWith(`-${color}`)) {
    url.searchParams.delete('color');
    redirect = true;
  }

  // 2. Page 1 duplicate: /collections/running/page/1/ → /collections/running/
  const page1 = url.pathname.match(/^\/collections\/([^/]+)\/page\/1\/?$/);
  if (page1) {
    url.pathname = `/collections/${page1[1]}/`;
    redirect = true;
  }

  return redirect ? NextResponse.redirect(url, 301) : NextResponse.next();
}

export const config = { matcher: ['/products/:path*', '/collections/:path*'] };

Fix 5: Sitemap lists only canonical URLs

Your sitemap lists /products/air-runner-white/?color=white. Build the sitemap with the same canonicalUrl() function so it can never disagree with your tags.

// app/sitemap.ts
import type { MetadataRoute } from 'next';
import { getAllProducts, getAllCollections } from '@/lib/commerce';
import { canonicalUrl } from '@/lib/canonical';

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
  const [products, collections] = await Promise.all([getAllProducts(), getAllCollections()]);
  return [
    ...collections.map((c) => ({ url: canonicalUrl(`/collections/${c.handle}/`), lastModified: c.updatedAt })),
    ...products
      .filter((p) => p.status === 'active') // live 200 pages only: no deleted or redirected URLs
      .map((p) => ({ url: canonicalUrl(`/products/${p.handle}/`), lastModified: p.updatedAt })),
  ];
}
  • If the sitemap comes from next-sitemap or from your commerce backend instead, find the code that adds ?color= and remove it.
  • Guess: if your product feeds (Merchant Center, affiliate feeds) use the same URL builder, they also carry ?color=. Switch them to canonicalUrl() too.

Fix 6: Internal links always point to the canonical URL

// Color swatches: link to the color page, not a parameter
<Link href={`/products/${variant.handle}/`}>{variant.colorName}</Link>
// not: <Link href={`?color=${variant.color}`}>
  • Product cards in collection grids and breadcrumbs should link to the color page (or to the hub, if you chose option A).
  • Keep trailing slashes consistent. Set trailingSlash: true in next.config.js, so /products/x 308-redirects to /products/x/.

Fix 7: Pagination points to itself and uses crawlable links

// app/collections/[handle]/page/[page]/page.tsx
import type { Metadata } from 'next';
import Link from 'next/link';
import { notFound } from 'next/navigation';
import { getCollection } from '@/lib/commerce';
import { canonicalUrl } from '@/lib/canonical';

type Props = { params: Promise<{ handle: string; page: string }> };

export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const { handle, page } = await params;
  return {
    title: `Running shoes – page ${page} | Example`,
    alternates: { canonical: canonicalUrl(`/collections/${handle}/page/${page}/`) }, // self, not page 1
  };
}

export default async function CollectionPage({ params }: Props) {
  const { handle, page } = await params;
  const n = Number(page);
  if (!Number.isInteger(n) || n < 2) notFound();
  const collection = await getCollection(handle, n);
  if (!collection || n > collection.totalPages) notFound(); // page 99 = real 404, not an empty 200

  return (
    <>
      {/* ...product grid... */}
      {n > 1 && <Link href={n === 2 ? `/collections/${handle}/` : `/collections/${handle}/page/${n - 1}/`}>Previous</Link>}
      {n < collection.totalPages && <Link href={`/collections/${handle}/page/${n + 1}/`}>Next</Link>}
    </>
  );
}
  • Use real <a href> links (<Link> renders them). A "Load more" button alone gives Google no crawlable path.
  • Sort and filter versions of a page (for example ?sort=price on page 2) should point to the clean page URL: /collections/running/page/2/.

Fix 8: Real error codes, not 200 "unavailable" pages

// lib/commerce.ts
export async function getProduct(handle: string) {
  const res = await fetch(`${process.env.COMMERCE_API}/products/${handle}`, { next: { revalidate: 300 } });
  if (res.status === 404) return null;                          // page calls notFound() → real 404
  if (!res.ok) throw new Error(`Commerce API ${res.status}`);   // → 500, so Google retries later
  return res.json();
}
  • In the product page, if (!product) notFound();.
  • If a product is gone for good, return a 404 or 410.
  • A sold-out product should keep its full content (photos, description, sizes) with a 200 and a "sold out" label. It should never be a bare "unavailable" message.
  • Don't put a loading.tsx in the product or collection routes. With streaming, Next sends the 200 status before your data loads. After that, notFound() can't change the status (Next only adds a noindex tag), and permanentRedirect() turns into a client-side redirect.

Fix 9: Follow up on court-classic-red (after Fix 1)

  1. Search Google for one unique sentence from your description, in quotes. This shows every copy, and whether other products are affected too.
  2. Compare the sneaker-deals.example page with yours. Is it the same text and photos? Does it have its own canonical? Did it publish before you?
  3. Then act on what you find:
    • Partner or affiliate using your feed: ask them to add noindex to their copy (the most reliable option), or a cross-domain canonical to https://www.example.com/products/court-classic-red/. You can also give them a different, shorter description than the one on your page.
    • Scraper: file a copyright (DMCA) removal request with Google. Make your page the fullest version, with a size guide, reviews and fit notes the copy doesn't have.
    • It's your own domain: 301 sneaker-deals.example/court-classic-red to your URL.

4. Recheck plan

Before you deploy (baseline)

  • Write down the 1,140 count. Export the examples (Search Console shows up to 1,000).
  • Save the URL Inspection results for the 4 URLs above.

Right after you deploy (check it yourself first)

  • Raw HTML should have exactly one canonical tag, and it should point to the page itself: curl -s https://www.example.com/products/air-runner-black/ | grep -io '<link[^>]*canonical[^>]*>'
  • The parameter URL should redirect to the clean URL: curl -sI "https://www.example.com/products/air-runner-white/?color=white" → expect 301 with location: /products/air-runner-white/.
  • Rendered HTML: URL Inspection → Test live URL → View tested page → HTML → search for "canonical". There should be exactly one tag, the same as the raw one. (The live test doesn't show the Google-selected canonical. Only the indexed result does.)
  • Whole site: crawl with JavaScript rendering on (Screaming Frog or Sitebulb). You want zero pages with two canonicals and zero raw/rendered mismatches.

Day 1

  • Resubmit the sitemap in Search Console.
  • Request indexing for the 4 URLs, /products/air-runner/ and your top products. The daily quota is small, so save it for key URLs.
  • Page indexing report → "Duplicate, Google chose different canonical than user" → Validate fix. Validation often takes 2 weeks or more.
  • Check your server logs or Crawl stats to confirm Googlebot actually re-fetched the fixed URLs.

What success looks like, and how long to wait

GroupCheck (URL Inspection, indexed result)Success looks likeWait before judging
A: color pages/products/air-runner-white/, /products/air-runner-black/Google-selected = user-declared = the color page. ?color=white shows "Page with redirect"First changes in 1–2 weeks. Judge at 4–6 weeks
B: pagination/collections/running/page/2/Google-selected = /collections/running/page/2/2–4 weeks
C: other domain/products/court-classic-red/Google-selected = your URL4–8 weeks. Both sites must be recrawled, and it can take longer with a scraper
Whole sitePage indexing reportThe 1,140 count keeps fallingWeekly checks. Judge the trend at 6 weeks

What to expect along the way:

  • "Page with redirect" will go up as the ?color= URLs redirect. That's expected and good.
  • The page-2+ URLs will move out of "Alternate page with proper canonical tag" and into indexed.
  • If validation shows "Failed" for some URLs, those URLs still have a conflicting signal. Fix them and start validation again.

If a URL still shows Google's own choice after 6 weeks, fill in the signal table again for that URL, find the signal that still points elsewhere, and fix that. Don't add extra tags to force your choice. Google only agrees once every signal points to the same URL.

The prompt

First lines open so you can see how it is built. The rest opens after purchase.

the prompt · 557 words7 sections
#ROLE
You are a technical SEO expert in duplicate content and canonicalization. Help me fix pages where Google ignores my canonical choice.

#INPUTS
Fill in every line. Leave a line blank if you don't know it.
- Website: [WEBSITE URL]
- Platform: [e.g., Shopify, WooCommerce, Next.js, custom]
- Affected URLs and the canonical Google chose instead (from URL Inspection): [LIST: my URL -> Google's choice]
Full prompt opens after purchase
Sections inside: #ROLE #INPUTS #FACTS #PROCESS #OUTPUT FORMAT #RULES #QUALITY CHECK

How to use it

  1. Buy, then open it in your account.
  2. Copy the prompt into ChatGPT, Claude or Gemini.
  3. Replace the 6 inputs with your product.
  4. Run it. Use the output. Re-run with a different tone if you like.

Pro tips

  • Copy Google's chosen canonical from URL Inspection for each URL. The pattern tells you which signal is winning.
  • Compare raw and rendered HTML. Two canonical tags after JavaScript runs is a very common cause.
  • If Google picked another website's URL, check for scrapers and bot challenge pages before anything else.

Before you buy

Will it work for my product?
Yes, if you can fill the 6 inputs. If the output is bad with your inputs, email us: we fix the prompt and refund you.
Do I download a file?
No. It lives in your account with a copy button, and updates when we improve it.
Which model is best?
Best on Claude. Works in ChatGPT, Claude and Gemini.

Works well with this

Prompts people use in the same campaign.

More in Site Structure, URLs & Media

See all in this sub-category

Buying more than two? Lifetime is cheaper.

Every prompt, every category, forever. $59 once. Nothing to download, nothing to renew.

Get lifetime · $59

This prompt

$3$7

  • ✓ Instant access in your account, with a copy button
  • ✓ Example input and real output included
  • ✓ 7-day money-back, no form

Or get every prompt, forever

Lifetime Access · $59 $149 — all categories, all future prompts, rewrites included.

Get lifetime access

Card or PayPal · taxes at checkout · nothing to download

Not the one you need?

Browse every prompt by category and sub-category.

Browse all prompts
Lifetime $59 →