Karachi, Pakistan Mon–Sat: 10AM–7PM PKT
Home Services
Design & Development
UI/UX Design Web Development WordPress Development Responsive Web Design Corporate Website Landing Pages / Microsites E-Commerce Solutions Mobile App Development
Marketing & Growth
SEO Services Content Marketing Social Media Marketing PPC / Google Ads Branding & Creative Speed & Performance
Hosting & Support
Web Hosting Maintenance & Support
Portfolio Clients About Blog Pricing Get a Quote
SEO & Speed Guide

What Is robots.txt? A Simple Guide With Safe Examples

A plain-language guide to robots.txt: what it does and does not do, safe examples for WordPress and stores, mistakes that hide sites from Google, and testing.

robots.txt file with user-agent, disallow and sitemap lines

robots.txt is a small text file at yourdomain.com/robots.txt that tells search engine crawlers which parts of your site they may or may not crawl. It is useful for keeping bots out of admin areas, search result pages and other low-value URLs. However, robots.txt does not hide pages from Google search results; to keep a page out of search, use a noindex tag instead. This guide explains the syntax, gives safe examples and shows how to test your file.

Key takeaways
  • robots.txt controls crawling, not indexing.
  • A single wrong line, such as Disallow: /, can block your whole site.
  • Add your sitemap address to robots.txt so all search engines can find it.

robots.txt syntax in plain language

LineMeaning
User-agent: *The rules below apply to all crawlers
User-agent: GooglebotThe rules below apply only to Google's crawler
Disallow: /private/Do not crawl anything in the /private/ folder
Allow: /private/info.htmlException: this file may be crawled
Sitemap: https://...Where to find your XML sitemap

The file must be called exactly robots.txt, in lowercase, and sit in the root folder of your domain.

Safe robots.txt examples

Allow everything (simplest)

User-agent: *
Disallow:

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

Typical WordPress site

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

Sitemap: https://yourdomain.com/sitemap_index.xml

Online store with internal search and cart pages

User-agent: *
Disallow: /cart/
Disallow: /checkout/
Disallow: /my-account/
Disallow: /?s=

Sitemap: https://yourdomain.com/sitemap.xml
Never block your CSS, JavaScript or image folders. Google needs them to see your pages the way visitors do, and blocking them can hurt how Google understands your mobile layout.

Common robots.txt mistakes

  • Disallow: / left in place after development, which blocks the entire site.
  • Using robots.txt to hide private pages. The file is public, so anyone can read which folders you list. Protect private areas with passwords instead.
  • Blocking a page you want removed from Google. If Google cannot crawl it, it cannot see a noindex tag, so the URL may stay in results.
  • Typos and wrong capitalisation, because paths are case-sensitive.
  • Several conflicting files or plugins editing robots.txt.

robots.txt vs noindex: which to use?

GoalUse
Stop bots wasting time on admin, cart or filter URLsrobots.txt Disallow
Keep a page out of Google search resultsnoindex meta tag (and allow crawling)
Keep content truly privatePassword protection or login

How to check and test robots.txt

  1. Open yourdomain.com/robots.txt in a browser to see the live file.
  2. In Google Search Console, open Settings > robots.txt to see the version Google fetched and any errors.
  3. Use URL Inspection on an important page to confirm it is not blocked.

Google's official reference is the robots.txt introduction in Search Central.

Frequently asked questions

What is robots.txt used for?

It tells search engine crawlers which parts of a website they may crawl.

Does robots.txt stop a page from appearing on Google?

Not reliably. Use a noindex tag to keep a page out of search results.

Where is robots.txt located?

In the root of your domain: yourdomain.com/robots.txt.

Do I need a robots.txt file?

It is not required, but a simple one with your sitemap address is good practice.

Want your technical SEO checked?

If your site is missing from search, read why your website is not showing on Google and our sitemap guide. Our SEO team can audit robots.txt, sitemaps and indexing for you. Contact us.

Written by the ItsWebExpert team, a web design and development company in Karachi building websites, online stores and apps for businesses across Pakistan.

Ask a Question on WhatsApp

Let's Build Your
Next Website

Tell us what you need and we will reply within 24 hours with honest advice and a fixed quote.