Web Development14 min read•

Web Development Company in Pune: robots.txt, noindex and Staging Sites — How to Keep the Wrong Pages Out of Google Without Blocking the Right Ones

robots.txt does not remove pages from Google. Learn when to use noindex, passwords or headers for staging sites, thank-you pages and search URLs, with an audit checklist.

#robots.txt#noindex#staging site#Google indexing#technical SEO

If you want Google to keep a page out of its results, the reliable tool is a noindex directive on a page that Google is still allowed to crawl, or a password in front of it — not a Disallow line in robots.txt. That single distinction is behind most of the "why is my staging site on Google?" and "why is my thank-you page showing up in search?" problems that a web development company in Pune is asked to fix. robots.txt controls whether crawlers may fetch a URL. Indexing is a separate decision, and a URL that is blocked from crawling can still appear in results as a bare link if other pages point to it, because Google never gets to read the page and see any instruction on it.

This guide is for business owners, marketing managers and in-house developers who have a live website and want to decide, page by page and folder by folder, what should and should not appear in search. It explains what robots.txt, the robots meta tag and the X-Robots-Tag header each do, which one to use for staging sites, admin areas, thank-you pages, internal search results and filtered product lists, the mistakes that quietly remove a whole site from Google, and how to check your own setup in Search Console. It does not promise any ranking change. Getting this right mostly prevents damage rather than creating gains.

Crawling and indexing are two different decisions

Search engines work in stages. First they discover a URL, then they crawl it (fetch the page), then they decide whether to index it (store it so it can be returned for queries). robots.txt sits at the first gate: it tells well-behaved crawlers which paths they may fetch. A noindex rule sits at the second gate: it tells a search engine that has fetched the page not to keep it in the index.

Google's own documentation on robots.txt states the practical consequence plainly: robots.txt is not a mechanism for keeping a page out of Google. If you block a URL in robots.txt but other sites or your own pages link to it, Google may still index the address, usually showing no description because it was never able to read the page. If you want the page out of results, Google's guidance is to use noindex or to protect the page with a password.

The trap that follows is the one people fall into most often. If you add a noindex tag to a page and then also block that page in robots.txt, Googlebot is not allowed to fetch the page, so it never sees the noindex tag, and the URL can stay in the index. The two instructions cancel each other out. To remove a page using noindex, the page must stay crawlable until Google has dropped it.

A quick comparison of the three tools

Tool Where it lives What it controls Works for non-HTML files such as PDFs Typical use
robots.txt One file at the root of the domain Whether a crawler may fetch a URL Yes, by path Saving crawl effort on low-value areas, blocking admin paths from well-behaved bots
Robots meta tag (<meta name="robots" content="noindex">) In the head of an HTML page Whether the page may be indexed and whether links on it are followed No Thank-you pages, internal search results, thin utility pages
X-Robots-Tag HTTP header Sent by the server with the response The same directives as the meta tag Yes PDFs, images, downloadable files, whole folders set by server rule

None of these is a security measure. robots.txt is publicly readable at yourdomain.com/robots.txt, so listing a private folder in it tells everyone where it is. Anything genuinely confidential needs authentication.

What robots.txt can and cannot do for a business website

A robots.txt file is a plain-text file placed at the root of the host, for example https://example.com/robots.txt. It must be at exactly that location; a robots.txt inside a subfolder is ignored. Each subdomain needs its own file, and the http and https versions of a host are treated separately, which is one more reason to settle on a single canonical version of your site, a topic covered in our guide to canonical URLs and the www versus non-www question.

A typical safe file for a small business site on WordPress looks like this:

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php

Sitemap: https://example.com/sitemap.xml

The Allow line exists because some themes and plugins load content on public pages through admin-ajax.php, and blocking it can stop search engines from seeing that content properly. The Sitemap line helps crawlers find your XML sitemap but is optional if you submit it in Search Console.

Rules that behave differently from what people expect

  • Paths are case sensitive. Disallow: /Private/ does not block /private/.
  • Google supports the * wildcard and the $ end-of-URL marker, but not every crawler does, so do not assume all bots interpret patterns the same way.
  • The most specific matching rule wins for Google, not the first one listed.
  • Google ignores any content of a robots.txt file beyond a size limit of 500 KiB, which a normal business site will never reach, but a generated file with thousands of lines can.
  • A noindex line inside robots.txt has not been supported by Google since 2019. Old advice that recommends it is out of date.
  • Compliance is voluntary. Reputable search engines follow robots.txt; scrapers and malicious bots do not.

Do not block the files a page needs to render

A habit from the early 2010s was to block the folders holding CSS and JavaScript. Google renders pages much like a browser, and if it cannot fetch the styles and scripts, it may misjudge the layout, miss content that is added by JavaScript, or conclude the page is not mobile friendly. Leave theme, plugin and asset folders crawlable unless you have a specific reason not to.

The staging site problem, and how to solve it properly

Almost every professionally built website passes through a staging or development copy on a subdomain or a temporary URL. Search engines can find these copies in surprisingly many ways: a link in an email that gets forwarded, a link in a shared document, an old sitemap, a referral from an analytics tool, or simply a guess at the subdomain name. When that happens you can have two copies of your site competing, one of them half finished, with placeholder text and test products.

Three methods are in common use, and they are not equal.

  1. HTTP authentication (a username and password at the server). This is the strongest option. Crawlers cannot get past it, humans need the credentials, and it protects the content itself rather than relying on any crawler's good behaviour. For a staging site, this should be the default.
  2. A noindex header on every response. Setting an X-Robots-Tag noindex header on the whole staging host is a reasonable second layer, useful when you cannot add a password because a client needs to preview from a phone without logging in. It still relies on the crawler reading the header.
  3. Disallow: / in robots.txt. This stops compliant crawlers fetching pages, but as explained above, URLs can still be listed if they are linked from elsewhere. It is the weakest of the three on its own.

The migration mistake that takes sites out of Google

The most expensive version of this problem runs in the opposite direction. The staging site has Disallow: / in robots.txt, or a noindex setting in the CMS, or a header rule at the server. When the site is launched, the files or the database are copied to the live server, and the block comes along with it. Nobody notices, because the site looks perfect in a browser. Over the following days or weeks, pages start dropping out of Google.

WordPress has a specific version of this. Under Settings, Reading, there is a checkbox labelled "Discourage search engines from indexing this site". WordPress's own description says it is up to search engines to honour the request. Developers tick it on staging, and the setting travels with a database copy. Make "untick the box, view the live robots.txt, and view the source of the home page" a named line item on your launch checklist. If you are moving to a new domain, the same checklist should sit alongside the redirect map described in our guide to changing your domain name or moving to HTTPS without losing rankings.

Which pages to keep out of search, and the right tool for each

Not every page on a site deserves to be in Google. The rule of thumb is to ask whether a person arriving from a search result would be glad they landed there. Pages that fail that test are candidates for noindex.

Page type Suggested approach Reasoning
Staging or development site HTTP authentication, plus noindex header Content must not be public at all
WordPress admin, login, cart-internal URLs Disallow in robots.txt, and normal login protection Saves crawling effort; the pages are not useful as results
Thank-you and order-confirmation pages Noindex meta tag, page left crawlable The page should not be a search landing page, but analytics tags still need to fire
Internal site-search results Noindex, or disallow the search path These pages are near-infinite and low value
Filtered and sorted product lists Depends on whether any combination has real search demand See the section on ecommerce below
Duplicate print versions, tag archives with a single post Noindex or consolidate with canonical tags Thin or repeated content
PDFs you do not want listed X-Robots-Tag noindex header A meta tag cannot be placed inside a PDF
Genuinely private documents Authentication; never rely on noindex or robots.txt Neither is a security control

Thank-you pages deserve a special note

Thank-you pages are often the pages where conversions are counted. If you block them in robots.txt, that does not stop a person's browser from loading them and firing your analytics tag, but it does mean Google cannot see the noindex tag you may have placed there. Use the meta tag and leave the page crawlable. If your ad platform counts a visit to the thank-you URL as a conversion, remember that anyone who finds the URL directly can inflate the count, which is a separate reason not to let it be indexed. We explain the tracking side in our article on order confirmation pages and tracking.

Internal search and filter URLs on ecommerce sites

Online stores generate enormous numbers of URLs through sorting, filtering and search. Most are variations of a few real pages. Blocking or noindexing all of them is the safe default, but a few filter combinations, such as a brand plus a category, may match what people really search for and deserve a proper, indexable page with its own heading and copy. The decision is a content decision first and a technical one second, and the full treatment is in our guide to faceted navigation and SEO.

How to apply noindex correctly

The meta tag

Place this in the head of the page:

<meta name="robots" content="noindex">

You can combine directives, for example noindex, nofollow, but for ordinary utility pages plain noindex is enough. Do not build a plan that depends on a noindexed page passing authority to other pages.

If a page is delivered through JavaScript rendering, make sure the tag is present in the HTML that Google ultimately renders. A common bug is a single-page application that ships a default index tag in the initial HTML and tries to change it later. When in doubt, use the URL Inspection tool and look at the rendered HTML.

The HTTP header

For files without an HTML head, the server must send the header. On Apache this is usually done with a Header directive inside a block that matches the file type, and on Nginx with an add_header directive inside a matching location. The syntax differs by server and hosting setup, so ask your developer or host to apply and test it, then confirm the header with a header-inspection tool or the browser's developer tools network panel.

Plugin settings in WordPress

SEO plugins such as Yoast SEO, Rank Math and All in One SEO let you mark individual pages, post types and taxonomies as noindex from the editor or settings. This is the easiest approach for most small business sites. The risk is the opposite of the technical one: a single global setting such as "do not index pages" applied to a post type, or a bulk edit, can silently remove many pages. After changing any indexing setting, spot-check the source of three or four pages.

A step-by-step audit you can run in an afternoon

  1. Open your robots.txt in a browser. Check that it exists at the root, that it does not contain Disallow: / under User-agent: *, and that it does not block your CSS, JavaScript or image folders.
  2. Check the robots.txt report in Search Console. Under Settings, Search Console shows the robots.txt files Google has found for the property, when they were last fetched, and any problems it encountered.
  3. View the source of your home page and two key service pages. Search for the word "robots". You should see either no robots meta tag or one that says index, follow. Seeing noindex on a page you want in search is an immediate fix.
  4. Open the Page indexing report in Search Console. Look at the "Not indexed" reasons. The ones relevant here are "Blocked by robots.txt", "Excluded by 'noindex' tag" and "Indexed, though blocked by robots.txt". Compare each list with your intentions. Thank-you pages under "noindex" are good. Service pages under "noindex" are a problem.
  5. Test a handful of URLs with the URL Inspection tool. For each, it shows whether the page is indexed, whether crawling is allowed, and which canonical Google selected. Use "Test live URL" after you make a fix.
  6. Search Google for site:yourdomain.com. It is not an exact count, but it is a quick way to spot staging subdomains, old test pages, or strange parameter URLs that should not be there. Search separately for your staging hostname if you know it.
  7. Check your XML sitemap. It should list only canonical, indexable URLs. A sitemap that includes noindex pages sends contradictory signals; remove them. Our guide to website structure and sitemap planning covers what belongs in it.
  8. Write down the result. Keep a short document listing which areas are blocked, which are noindexed, and why. When the site is rebuilt in two years, this file saves a great deal of guesswork.

Removing something that is already in Google

If a page or a site has already been indexed and you want it gone, the correct response depends on the urgency.

  • Not urgent. Add noindex (leaving the page crawlable) or remove the page so that it returns a 404 or 410 status, and wait for Google to recrawl. This can take days to weeks depending on how often the page is crawled.
  • Urgent, such as confidential material exposed. First secure the content with authentication or take it down. Then use the Removals tool in Search Console to request temporary removal. Google's documentation describes this as a temporary hide of roughly six months, so the underlying cause must also be fixed, otherwise the page may return.
  • A page on a site you do not control. Different processes apply; the Removals tool covers only properties you have verified.

Do not use the Removals tool as a substitute for fixing the page. It is a stopgap.

AI crawlers and robots.txt: a separate question

Since 2023 many site owners have added rules for AI-related crawlers to robots.txt. That is a legitimate and separate decision from the search indexing questions above, because blocking a crawler that gathers data for AI products is a different choice from blocking Googlebot. The two should not be confused. A careless wildcard rule meant to stop one bot can end up blocking all of them. If you are weighing that decision, our article on AI crawlers and robots.txt sets out the trade-offs, and the same advice applies here: test every change against the specific user-agent you care about.

Mistakes we would check first on any inherited website

  • Disallow: / left over from staging.
  • WordPress "Discourage search engines" ticked on the live site.
  • A noindex tag on a template, so every page of a type is excluded.
  • A noindex page that is also blocked in robots.txt, so the tag is never read.
  • A sitemap that lists redirected, noindexed or blocked URLs.
  • A robots.txt that returns an error. Per Google's documentation, a robots.txt that keeps returning a server error (5xx) can make Google pause crawling of the site, while a missing file (404) is treated as no restrictions. Keep the file available and returning 200.
  • Different robots.txt files on the www and non-www hosts, or on http and https.
  • Blocked resource folders that stop Google rendering the page.
  • A CDN or security tool that serves a different robots.txt or a challenge page to crawlers.

When this is more than a checklist

For a ten-page brochure website, the audit above takes an hour and a careful developer can fix everything. For a large store, a site with many languages, or an application built in a JavaScript framework, indexing control is part of the architecture: which URLs exist, how they are generated, and how they are rendered for crawlers. If your team is commissioning a new build, put indexing rules in the brief and ask for the staging protection method, the launch-day check and the post-launch monitoring to be written down. The same thinking goes into how we plan website structure before design starts.

Frequently Asked Questions

Does blocking a page in robots.txt remove it from Google?

No. Blocking stops compliant crawlers from fetching the page, but Google may still list the URL, without a description, if other pages link to it. To keep a page out of results, use a noindex directive on a crawlable page, or protect the page with a password.

Can I use both noindex and a robots.txt Disallow on the same page?

You should not. If robots.txt blocks the page, Googlebot cannot fetch it and will never see the noindex instruction, so the URL may remain in the index. Allow crawling until the page has dropped out of search, then decide whether to block it.

Should I noindex my thank-you page?

Usually yes. A thank-you page is rarely a good landing page from search, and indexing it can let people trigger your conversion tracking without enquiring. Use a noindex meta tag, leave the page crawlable, and check that your analytics tag still fires.

How do I stop my staging website appearing on Google?

Put HTTP authentication on the staging host, which keeps both people and crawlers out, and add a noindex header as a second layer if you need it. Before launch, confirm that none of these settings have been copied to the live site.

How long does it take for noindex to work?

It takes effect when Google next crawls the page and processes the tag. That can be a few days for a frequently crawled page and several weeks for a rarely visited one. Requesting indexing in the URL Inspection tool can prompt a recrawl but does not guarantee a time.

Where to Start

Open yoursite.com/robots.txt today and read it line by line. Then view the source of your home page and search for "noindex". If either contains something you cannot explain, ask your developer to explain it in writing. Those two five-minute checks catch the most damaging errors.

Govindani Infotech is a website design and development company in Pune, at Landmark Plaza, Satara Road, Parvati Paytha. If you are planning a new site or want an independent review of an existing one, see our website creation services and our SEO services, or contact us or call 092019 58274.

Sources:

Need Help With Your Digital Strategy?

Govindani Infotech helps Indian businesses and NGOs build websites, run ads, and grow online. Contact us for a free consultation.