Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Canonical pointing to staging domain: how to find and fix it

SEO-045High impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

A canonical tag is a line in the head of a page, <link rel="canonical" href="...">, that tells search engines which URL is the main version of that content. When a site is built on a staging or development copy, the tag is often generated from that copy's address. If the site goes live without the address being updated, every live page still says its canonical is the staging URL.

Example of the problem in the page headhtml
<!-- Live page: https://www.example.com/pricing/ -->
<link rel="canonical" href="https://staging.example-agency.com/pricing/" />

Why it costs you leads or sales

How a staging canonical loses organic leads
  1. Live pageLoads fine on your real domain
  2. Canonical tagNames the staging domain
  3. Google indexLive URL treated as a duplicate
  4. Search trafficFewer visitors arrive
  5. Leads and salesFewer enquiries and orders

The page works for visitors, but search engines are sent elsewhere.

Organic visits before and after a bad canonicalExample numbers
Organic visits before and after a bad canonical (example)Launch: 1,000 visits per week; Week 2: 850 visits per week; Week 4: 500 visits per week; Week 6 (fixed): 600 visits per week; Week 10: 950 visits per week03837671,000850500600950LaunchWeek 2Week 4Week 6 (fixed)Week 10visits per week

Example: illustrative numbers showing how organic visits can fall over several weeks after launch, then recover once the canonical is fixed and pages are re-crawled.

How to check if your site has it

Check your canonicals in a few minutes
  1. View the page source

    Open a live page, right-click, choose View page source and search for canonical. Check that the domain in the href is your live domain.

  2. Check several page types

    Test the home page, a service or product page, a blog post and a category page. Templates can differ.

  3. Use Google Search Console URL Inspection

    Inspect a live URL and open the Page indexing details. Look at User-declared canonical and Google-selected canonical. A staging domain here confirms the problem.

  4. Search for the staging domain

    Search Google for site:staging.yourdomain.com (use your real staging address) to see if it has been indexed.

  5. Crawl the site

    Run a crawler such as Screaming Frog or Sitebulb and filter the canonical column for any URL not on your live domain.

How to fix it

Fix the canonical by platform
  1. Correct the site address

    Go to Settings > General and set WordPress Address and Site Address to your live https URL. If the fields are greyed out, check WP_HOME and WP_SITEURL in wp-config.php.

  2. Check your SEO plugin

    In Yoast SEO, Rank Math or similar, look for a custom canonical set on the page and for any hard-coded domain in settings. Clear the custom canonical field if it names staging.

  3. Fix stored URLs

    If the database was copied from staging, run a search-and-replace for the staging domain, for example with WP-CLI wp search-replace. Take a backup first.

  4. Clear caches

    Purge your caching plugin, server cache and CDN so the new head is served.

Example: build the canonical from a configured base URLphp
<?php
$base = rtrim(getenv('SITE_URL'), '/'); // e.g. https://www.example.com
$path = strtok($_SERVER['REQUEST_URI'], '?');
?>
<link rel="canonical" href="<?= htmlspecialchars($base . $path) ?>" />

How to confirm it's fixed

Confirm the fix
  • View source on the home page and key pages: the canonical shows your live https domain.
  • Search the source of each template type for the staging domain: no matches.
  • Run a crawl and confirm no canonical points off your live domain.
  • In Search Console, use URL Inspection > Test live URL, then Request indexing for your most important pages.
  • Submit an updated XML sitemap that lists only live URLs.
  • Recheck after a week: Google-selected canonical matches the user-declared one.

How to prevent it happening again

Add these to every launch and migration
  • Keep a launch checklist with a step to view source and check the canonical on five page types.
  • Store the site address in one setting per environment, not in templates.
  • When you copy a database from staging, run a search-and-replace for the staging domain straight away.
  • Password protect staging so it cannot be indexed.
  • Do not push staging SEO plugin settings or custom canonicals to production.
  • Crawl the live site after each launch and filter for off-domain canonicals.
  • Watch Search Console for sudden drops in indexed pages.

How FunnelGuard handles this

What FunnelGuard does cover nearby: a robot visitor runs your real customer journeys on a schedule (lead forms, checkouts, booking and chat buttons) and checks each step, the tracking hits and whether test leads arrive. That helps you notice when a launch breaks a form or tag, but it will not tell you your canonical is wrong. A free plan (1 site, 2 journeys, daily checks) and a free read-only website audit are available.

To watch for this yourself, schedule a crawl in a tool such as Screaming Frog after each release, set up Search Console email alerts, and check the Pages report for a sudden rise in Duplicate, Google chose different canonical than user pages.

Questions people ask

Why is my canonical tag pointing to my staging site?

Usually the site address setting was copied from staging when the site went live, or a theme, plugin or template has the staging domain hard-coded. Correct the setting or template so it uses your live domain, then clear caches.

How do I check what canonical URL a page uses?

Open the page, view the source and search for rel="canonical". The href shows the declared canonical. You can also use Google Search Console URL Inspection to see the user-declared and Google-selected canonical.

Can a staging canonical remove my site from Google?

It can cause live pages to be treated as duplicates of the staging URL, so they may be dropped from results or replaced by the staging page. Google treats the canonical as a hint, so the effect varies, but it is a serious risk for organic traffic.

How long does it take Google to recover after I fix the canonical?

It depends on how often Google re-crawls your pages. Request indexing for key pages in Search Console and submit a clean sitemap to speed it up. Larger sites can take weeks.

Should I block my staging site from search engines?

Yes. Put it behind a password where you can, since this is more reliable than noindex or robots.txt alone. Make sure those blocks are never copied to the live site.

How do I find every page with a wrong canonical?

Crawl your site with a tool such as Screaming Frog or Sitebulb and filter the canonical column for URLs not on your live domain. Also search your database or code for the staging domain.

Does FunnelGuard detect a wrong canonical tag?

No. FunnelGuard does not check canonical tags at the moment. It monitors journeys such as forms and checkouts, tracking hits and test leads, so use a crawler and Search Console for canonicals.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.