Robots.txt Guide for Beginners: What It Does and How to Write One
It is a tiny text file, and one wrong line in it can remove an entire website from search.

In this article
- The directives
- A safe starting file
- The line that hides a whole site
- What robots.txt does not do
- What is worth blocking
- AI crawlers
- Related developer tools
- Generate and test
- FAQs
- What is robots.txt used for?
- Where does the robots.txt file go?
- Does Disallow remove a page from Google?
- Does every website need a robots.txt?
Robots.txt is a plain text file at the root of a website — yoursite.com/robots.txt — that tells search engine crawlers which parts of the site they may request. It is one of the first things a crawler reads. It is also short, easy to get wrong, and capable of doing real damage when it is.
The directives
- User-agent — which crawler the rules below apply to. An asterisk means all of them.
- Disallow — a path the crawler should not request.
- Allow — an exception inside a disallowed path.
- Sitemap — the full address of your XML sitemap.
A safe starting file
User-agent: *
Disallow: /admin/
Disallow: /cart/
Disallow: /checkout/
Disallow: /search
Sitemap: https://www.example.com/sitemap.xml
This lets crawlers reach everything public and keeps them out of areas that are private or produce endless duplicate pages.
The line that hides a whole site
User-agent: *
Disallow: /
A single slash blocks everything. It is commonly left behind after a site is built on a staging server, and it is one of the most frequent causes of "my site has disappeared from Google". Check for it first.
What robots.txt does not do
- It does not remove a page from Google. Disallow stops crawling, not indexing. A blocked page that other sites link to can still appear in results, without a description. To keep a page out of search, allow it to be crawled and add a noindex tag.
- It is not security. The file is public, and badly behaved bots ignore it. Never list secret paths in it; protect them with a login.
- It does not block resources safely. Blocking your CSS or JavaScript stops Google rendering the page properly.
What is worth blocking
- Admin and login areas
- Cart, checkout and account pages
- Internal search result pages
- Filter and sort combinations that create thousands of near-identical addresses
AI crawlers
Robots.txt is also where you state a preference for AI crawlers such as GPTBot, ClaudeBot and Google-Extended. You can allow or disallow each by its user-agent name. For the newer companion file aimed at AI systems, see what is llms.txt.
Related developer tools
When you are cleaning up a site's technical side, two small utilities help: the HTML to Text Converter shows the plain text a crawler sees in a block of markup, and the Base64 Encoder and Decoder handles encoded values in configuration files.
Generate and test
The Robots.txt Generator builds a correct file from a few choices, including the sitemap line and AI-crawler rules. After uploading it, open yoursite.com/robots.txt in a browser to confirm it is live, and check the robots.txt report in Google Search Console.
Related: on-page SEO guide for beginners · local SEO for Pakistani businesses
FAQs
What is robots.txt used for?
To tell search engine crawlers which parts of a site they may or may not request.
Where does the robots.txt file go?
In the root folder of the domain, so it loads at yoursite.com/robots.txt.
Does Disallow remove a page from Google?
No. It prevents crawling. Use a noindex tag to keep a page out of the index.
Does every website need a robots.txt?
It is not compulsory, but it is good practice — at minimum to point crawlers to the sitemap.
Learn it properly
Turn this knowledge into income
Join a practical, mentor-led course at OEC Tech Institute — on campus in Chunian or online.


