deindexpages.com
Page types

Removing staging and dev sites from Google

A staging site in Google results is more than embarrassing. It can expose unfinished content, duplicate your production pages and confuse users. The fix has two parts: get what is indexed out quickly, and make sure it cannot happen again.

Why staging sites get indexed

  • A link to the staging hostname leaked into a public page, email, ticket, or sitemap.
  • The staging environment had no authentication and the crawler found it.
  • A robots.txt disallow was used as the only protection, which Google says is not a way to keep a page out of Google. See why robots.txt does not deindex.
  • A deploy copied production settings (or the reverse) and changed robots rules by accident.

The right protection, in order of reliability

LayerStrengthNotes
HTTP basic auth, SSO, or IP allowlistStrongCrawlers cannot fetch what they cannot access. Google lists password protection as a permanent removal option.
noindex header on the whole hostMediumWorks if crawlers can reach the pages; a good backstop
noindex meta tag in templatesMediumEasy to carry over to production by mistake
robots.txt disallowWeak for indexingReduces crawling only

Use authentication as the primary control and a host-wide X-Robots-Tag noindex header as the backstop.

Emergency: staging is already indexed

  1. Add authentication now, or take the environment offline if you can. If the content is gone or locked, Google will eventually drop it.
  2. Verify the staging hostname in Search Console. The Removals tool needs a verified property. Staging subdomains are separate properties; Google's help notes that blocking the root URL of a property does not affect subdomains such as staging. Verification can be done with a DNS record on a Domain property, an HTML file or a meta tag.
  3. File a prefix removal for the staging site's root. In the Removals tool, choose "Remove all URLs with this prefix". It hides www, non-www, http and https variants of that prefix, per Google's help page.
  4. Do not rely on that alone. It lasts about six months. Keep authentication in place so that nothing returns. If you cannot add auth immediately, return 404/410 for all paths or serve a host-wide noindex that crawlers can reach.
  5. Remove the staging hostname from any sitemap, public link, or analytics tag that leaked it.
  6. Check back. Search for site:staging.example.com as a rough check and use URL Inspection on a few URLs.

If you add authentication after the pages are indexed, Google receives 401 or 403 responses. Google treats 4xx errors the same way for indexing, so previously indexed URLs are expected to drop after recrawl. A removal request makes them disappear sooner.

Preventing it next time

The opposite problem: staging noindex reaches production

When a noindex header or tag from staging is carried over in a deploy, production pages start dropping from the index after Google recrawls. It is one of the most expensive launch mistakes because it silently removes pages you want.

  1. Remove the noindex immediately and deploy.
  2. Confirm with curl -I and view-source on key URLs.
  3. Check robots.txt for an accidental Disallow: /.
  4. Resubmit the sitemap and request indexing on key pages in URL Inspection.
  5. Monitor the Page indexing report for "Excluded by 'noindex' tag" and drops in impressions.

Prevent it with a post-deploy check that fetches the home page and a few templates and fails if a noindex directive is present.

Preview deployments on hosting platforms

Many hosting platforms create a public preview URL per branch or pull request. Treat them like staging: enable the platform's access control for previews where offered, or send a noindex header via the preview configuration. If a platform provides a default subdomain for your site (for example a project subdomain), decide whether that default host should be indexable, and redirect it to your custom domain once live.

Cleaning up duplicate content from a public default domain

If your site is available on a default platform domain and a custom domain, Google may index both. Redirect the default domain to the custom domain with a 301 and set canonicals to the custom domain. See canonical tags and deindexing.

Verification

Confirm that fetching the staging URL anonymously returns a login prompt or error, not content. Confirm that Search Console shows the staging URLs as not indexed after Google recrawls, and that the Removals tool request is active. Follow how to verify a page is deindexed for details.

Who should own this

Indexing of non-production environments is a shared responsibility between developers, whoever manages the hosting, and whoever owns SEO. Write the rule down: every new environment is created behind authentication, and its hostname is added to an inventory. When a contractor builds a prototype on their own domain for you, ask them to add authentication and a noindex header, and ask for the hostname so that it can be tracked and removed when the project ends. Expired prototypes are a frequent source of unexpected indexed pages that nobody remembers creating.

Frequently asked questions

Is robots.txt enough to protect a staging site?

No. Disallowed URLs can still be indexed if they are linked, shown without a description. Use authentication.

Will a staging removal in Search Console remove production pages?

Not if you file it in the staging subdomain's own property. Subdomains are separate properties, and a prefix removal is scoped to the property.

How long does the Removals tool keep staging hidden?

About six months. Authentication is what keeps it hidden permanently.

Should I noindex staging too?

Yes, as a backstop, but make sure the setting cannot reach production in a deploy.