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.
<!-- Live page: https://www.example.com/pricing/ -->
<link rel="canonical" href="https://staging.example-agency.com/pricing/" />Why it costs you leads or sales
- Live pageLoads fine on your real domain
- Canonical tagNames the staging domain
- Google indexLive URL treated as a duplicate
- Search trafficFewer visitors arrive
- Leads and salesFewer enquiries and orders
The page works for visitors, but search engines are sent elsewhere.
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
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.Check several page types
Test the home page, a service or product page, a blog post and a category page. Templates can differ.
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.
Search for the staging domain
Search Google for
site:staging.yourdomain.com(use your real staging address) to see if it has been indexed.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
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.
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.
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.Clear caches
Purge your caching plugin, server cache and CDN so the new head is served.
Check the primary domain
In Settings > Domains, make sure your live domain is the primary domain. Shopify builds canonicals from it.
Search the theme
In Online Store > Themes > Edit code, search theme.liquid for
canonical. It should use{{ canonical_url }}, not a typed address.Check apps
SEO apps can inject their own tags. Disable them one at a time and recheck the source.
Set the canonical domain
In Site settings > Publishing, set your custom domain as the default domain and republish.
Check page settings
In each page's SEO settings and in Site settings > SEO, remove any custom canonical that names a webflow.io or staging address.
Publish to the live domain
Publish again so the change reaches the live site.
Check the primary domain
Confirm your live domain is connected and set as primary in your domains settings.
Review SEO settings
In each page's SEO settings, look at Advanced SEO tags and remove any custom canonical or link tag that names another domain.
Set the primary domain
In Settings > Domains, make sure your live domain is the primary one.
Check code injection
In Settings > Advanced > Code Injection, remove any hand-written canonical tag that names another domain.
Check the connected domain
In the funnel or website settings, make sure your live custom domain is connected and set on each page.
Check tracking code
Open the page's Settings > Head tracking code and the funnel's custom code. Remove any canonical tag that names a staging or preview address, then republish.
Look for tags that write canonicals
Search your container for Custom HTML tags that insert a link rel=canonical. A tag copied from staging may hard-code the wrong domain.
Fix or remove the tag
Change the domain, or remove it and output the canonical from your CMS instead. Preview, then publish a new version.
Find the base URL setting
Search the codebase and environment variables for the staging domain. Typical names are BASE_URL, SITE_URL or APP_URL.
Set it per environment
Set the production value to your live https domain and deploy. Avoid hard-coding domains in templates.
Build the canonical from config
Output the tag from that setting, as in the snippet below.
<?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
- 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
- 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.
Related issues
- SEO-042Missing rel=canonical on indexable pagesFix guide
- SEO-043Canonical points to a 404, redirect or noindex URLFix guide
- SEO-050Cross-domain canonical to a partner or old domain by mistakeFix guide
- SEO-052Google chose a different canonical than declaredFix guide
- SEO-064Preview or tracking subdomain duplicates the main siteFix guide
- SEO-065Mirror domain or IP address serves the site with 200Fix guide