Skip to main content

How a robots.txt file works

What is Robots.txt file and how to create a perfect Robots.txt file

Robots.txt file is a small text file that resides in the root folder of your site. It tells the search engine bots which part of the site to crawl and index and which part not.

If you make even a slight mistake while editing/customizing it, then the search engine bots will stop crawling and indexing your site and your site will not appear in the search result.

In this article, I will tell you what is Robots.txt file and how to create a perfect Robots.txt file for SEO.

Why Robots.txt is necessary for the website

When search engine bots come to the website and blog, they follow the robots file and crawl the content. But if your site does not have Robots.txt file, then the search engine bots will start indexing and crawling all the content of your website which you do not want to index.

Search engine bots look for robots file before indexing any website. When they do not get any instructions from Robots.txt file, then they start indexing all the content of the website. And if they get any instructions, then they index the website by following them.

So, due to these reasons, Robots.txt file is required. If we do not give instructions to search engine bots through this file, then they index our entire site. Along with this, they also index some such data which you did not want to index.

Benefits of Robots.txt file

  • Search engine tells bots which part of the site to crawl and index and which part not.
  • A particular file, folder, image, pdf etc. can be prevented from being indexed in search engine.
  • Sometimes search engine crawlers crawl your site like hungry lions, which affects your site 
  • performance. But you can get rid of this problem by adding crawl-delay to your robots file. 
  • Although Googlebot does not accept this command. But you can set the crawl rate in Google 
  • Search Console. This prevents your server from getting overloaded.
  • You can make the entire section of any website private.
  • You can prevent the internal search results page from showing in SERPs.
  • You can improve your website SEO by blocking low quality pages.

Where does the Robots.txt file reside in the website?

If you are a WordPress user, it resides in the root folder of your site. If this file is not found in this location, then the search engine bots start indexing your entire website. Because search engine bots do not search your entire website for Robots.txt file.

If you do not know whether your site has a robots.txt file or not? So in the search engine address bar, you just have to type this – example.com/robots.txt

https://www.knowledgeplus.tech/2024/11/How a robots.txt file works.html


A text page will open in front of you as you can see in the screenshot.

This is the robots.txt file of knowledge.tech. If you do not see any such txt page, then you have to create a robots.txt file for your site.

Apart from this, you can check it by going to Google Search Console tools.

Basic Format of Robots.txt File

The basic format of Robots.txt file is very simple and it looks something like this,

User-agent: [user-agent name]

Disallow: [URL or page you do not want to crawl]

These two commands are considered a complete robots.txt file. However, a robots file can have many commands of user agents and directives (disallows, allows, crawl-delays etc.).

User-agent: Search Engines are Crawlers/Bots. If you want to give the same instruction to all search engine bots, then use the * symbol after User-agent:. For example – User-agent: *

Disallow: This prevents files and directories from being indexed.

Allow: This allows search engine bots to crawl and index your content.

Crawl-delay: How many seconds the bots have to wait before loading and crawling the page content.

Preventing all web crawlers from indexing the website

User-agent: *

Disallow: /

By using this command in the Robots.txt file, you can prevent all web crawlers/bots from crawling the website.

Allowing all web crawlers to index all content

User-agent: *

Disallow:


This command in Robots.txt file allows all search engine bots to crawl all pages of your site.

Blocking a Specific Folder for Specific Web Crawlers

User-agent: Googlebot

Disallow: /example-subfolder/


This command only stops Google crawler from crawling example-subfolder. But if you want to block all crawlers, then your Robots file will be like this.

User-agent: *

Disallow: /example-subfolder/


Preventing a Specific Page (Thank You Page) from being indexed

User-agent: *

Disallow: /page URL (Thank You Page)


This will prevent all crawlers from crawling your page URL. But if you want to block specific crawlers, then write it like this.

User-agent: Bingbot

Disallow: /page URL

This command will only prevent Bingbot from crawling your page URL.

Adding Sitemap in Robots.txt File

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

You can add your sitemap anywhere in robots.txt – at the top or at the bottom. Here is a guide – How to Add Sitemap in Robots.txt File and Why it is Important?

You can comment for any kind of question or suggestion related to this article. If this article proved helpful for you, then don’t forget to share it!

Comments

Popular posts from this blog

Home Loan: Banks Provide 5 Types of Loans

Home Loan: Banks provide 5 types of home loans, know which one will be beneficial for you Home Loan: Banks provide 5 types of loans. Customers can take home loans according to their needs. Home Loan: We all have a dream of having our own house. Many times people take loans from banks to buy houses. Financial advisors say that knowing about different homes is a profitable deal because you take home loans according to your needs and are able to save a lot. So let's know the 5 types of home loans and their benefits. Types of Home Loans Home Purchase Loan: Taken to buy a house. Home Improvement Loan: Taken for repair/renovation of the house. Home Construction Loan: Taken to build a new house. Land Purchase Loan: Taken to buy a plot to build your own house.   1. Home loan for house construction- If you want to build your own house, you can take a home purchase loan. It can include the cost of the plot as well as the cost of building the house. The price of the plot is included only...

Earn money from mobile

Earn money from mobile: If you want to earn money from your mobile and want to know how to earn money from mobile, then you have come to the right place. In this article, we will tell you easy ways to earn money from mobile, by which you can easily earn money sitting at home using mobile. Today there are lakhs of people in India who are earning a good amount every month only from their mobile. The best thing in this is that to earn money from mobile, you do not need much experience and education and neither do you have to make any kind of investment, but due to increasing competition, it is not that earning money is at all easy. In such a situation, if you also want to earn money from mobile, then let's start knowing about the easiest and free ways to earn money from mobile through this article. Earn money from mobile?  How to earn money from mobile? Today almost everyone in India has a smartphone and most people waste their precious time watching reels videos, there are very few p...