Web development

How to Keep a Staging Site Out of Google

Two laptops on a workbench, one labeled as a draft site and one as the public site, with a paper note that says noindex

A staging site is the copy you use before launch: a temporary hostname, a preview link, a half-built homepage. It should not compete with the real site in search. Google's guide for a move that does not change URLs says the temporary hostname should be noindex [1]. The mistake is blocking that hostname in robots.txt and assuming the block is the same thing.

Why does robots.txt fail as a hide switch?

robots.txt manages crawl. It does not reliably keep an HTML page out of Google. A disallowed URL can still be indexed without a snippet if something else links to it [2]. To hide a page, Google says to use noindex or a password, not a disallow [2]. A staging site that is only disallowed can still show up as a bare URL.

How does noindex actually work?

noindex can be a meta robots tag or an X-Robots-Tag HTTP header. Google has to crawl the page to see it. If robots.txt blocks the page, Google never sees the noindex, and the URL can still appear [3]. A noindex line inside robots.txt is not supported [3]. The rule has to be on the page, and the crawler has to be allowed to read the page.

How long does a test URL stay in results?

Removing a URL that is already indexed can take months [3]. Putting noindex on a staging site after it has been linked from a tweet or an old sitemap does not erase it the same day. Google says you can use URL Inspection to ask for a recrawl [3]. Ask, then wait. Do not launch a second copy and hope the first one vanishes overnight.

What should you remove before the real site goes live?

The blocks. Google's no-URL-change move guide says to remove noindex and robots.txt blocks before the DNS cut, because those blocks will keep the live site from being crawled if you forget them [1]. A staging noindex that ships to production is how a finished site stays invisible. Check the homepage response on the real domain the morning you point DNS.

What does a hosting move do to crawl?

When the URLs stay the same and only the server changes, Google says to lower the DNS TTL to a few hours at least a week ahead, and to shut the old host when traffic there is zero [1]. Crawl rate often dips and then rises [1]. That dip is not a reason to leave the staging copy indexed as a backup. One hostname should be the site. The other should be noindex until you delete it.

Should the staging copy be in the sitemap?

No. A sitemap helps discovery and does not guarantee indexing, and it is the list of URLs you want found [4]. A staging hostname in that file is an invitation. The live sitemap should list the public URLs only. A small, well-linked site of about 500 pages or fewer may not need a sitemap at all [4]. It still should not advertise the test address.

What if the staging URL returns an error on purpose?

A password wall is the other hide method Google names [2]. A 404 is for a URL that is gone, and Google ignores 4xx content other than 429 [5]. Using a 404 as the entire staging site makes the preview useless to you. noindex or a password keeps the pages available to the people building them. A 404 does not.

What should you not stack on launch day?

A new domain, a redesign, and a forgotten noindex. Google's Change of Address tool is only for a domain or subdomain move, not for http to https, a www change, a path change, or a hosting-only move, and it warns that combining a move with a redesign causes traffic loss [6]. A staging site is none of those tools. It is a copy. Keep it out of the index, then remove the block from the copy that becomes the real site.

  • noindex on the test hostname — meta tag or X-Robots-Tag, on a page Google can fetch.
  • Do not disallow that host — a block hides the noindex.
  • Leave it out of the sitemap — the sitemap is a discovery list.
  • Strip the noindex at launch — before DNS points at the new server.
  • Password the copy — if noindex is not enough for a client preview.

What if someone already shared the preview link?

Treat it as indexed until you have checked. A link from another site is enough for Google to know the URL exists, and a disallow will not keep that URL out of results [2]. Put noindex on the preview, allow the crawl so the tag can be seen, and use URL Inspection if you need a recrawl [3]. Then stop sending the preview link in public posts.

Who usually leaves the block in place?

Whoever copies the staging config into production and does not read the homepage headers. That is ordinary website development hygiene, and it belongs on the launch checklist next to the form and the phone number. Maintenance is the later check that a preview link did not get indexed after a redesign. If you are about to change hosts, how hosting works for a small site is the other half of the same week.

Sources & references

  1. Google Search Central: Site moves without URL changes.
  2. Google Search Central: Introduction to robots.txt.
  3. Google Search Central: Block search indexing with noindex.
  4. Google Search Central: Learn about sitemaps.
  5. Google Search Central: HTTP status codes and network errors.
  6. Google Search Console Help: Change of Address tool.

Crawl and noindex behavior is described on the linked Google pages. Confirm the current page before you change a live robots file.

If a test address is showing up next to the real site, we can check whether the block is the kind Google can see.

Talk to us arrow_right_alt