Understanding tips on how to use the robots.txt file is essential for any web site’s search engine optimization technique. Mistakes in this file can influence how your web site is crawled and your pages’ search look. Getting it proper, however, can enhance crawling effectivity and mitigate crawling points.
Google recently reminded web site house owners in regards to the significance of utilizing robots.txt to dam pointless URLs.
These embody add-to-cart, login, or checkout pages. However the query is – how do you employ it correctly?
On this article, we are going to information you into each nuance of tips on how to just do so.
What Is Robots.txt?
The robots.txt is an easy textual content file that sits within the root listing of your website and tells crawlers what must be crawled.
The desk under supplies a fast reference to the important thing robots.txt directives.
Directive | Description |
Consumer-agent | Specifies which crawler the principles apply to. See user agent tokens. Utilizing * targets all crawlers. |
Disallow | Prevents specified URLs from being crawled. |
Permit | Permits particular URLs to be crawled, even when a mum or dad listing is disallowed. |
Sitemap | Signifies the placement of your XML Sitemap by serving to search engines like google to find it. |
That is an instance of robotic.txt from ikea.com with a number of guidelines.
Observe that robots.txt doesn’t help full common expressions and solely has two wildcards:
- Asterisks (*), which matches 0 or extra sequences of characters.
- Greenback signal ($), which matches the tip of a URL.
Additionally, observe that its guidelines are case-sensitive, e.g., “filter=” isn’t equal to “Filter=.”
Order Of Priority In Robots.txt
When establishing a robots.txt file, it’s essential to know the order during which search engines like google resolve which guidelines to use in case of conflicting guidelines.
They observe these two key guidelines:
1. Most Particular Rule
The rule that matches extra characters within the URL will probably be utilized. For instance:
Consumer-agent: *
Disallow: /downloads/
Permit: /downloads/free/
On this case, the “Permit: /downloads/free/” rule is extra particular than “Disallow: /downloads/” as a result of it targets a subdirectory.
Google will enable crawling of subfolder “/downloads/free/” however block every thing else underneath “/downloads/.”
2. Least Restrictive Rule
When a number of guidelines are equally particular, for instance:
Consumer-agent: *
Disallow: /downloads/
Permit: /downloads/
Google will select the least restrictive one. This implies Google will enable entry to /downloads/.
Why Is Robots.txt Essential In search engine optimization?
Blocking unimportant pages with robots.txt helps Googlebot focus its crawl budget on beneficial components of the web site and on crawling new pages. It additionally helps search engines like google save computing energy, contributing to higher sustainability.
Think about you’ve gotten a web-based retailer with lots of of 1000’s of pages. There are sections of internet sites like filtered pages that will have an infinite variety of variations.
These pages don’t have distinctive worth, primarily comprise duplicate content material, and will create infinite crawl area, thus losing your server and Googlebot’s sources.
That’s the place robots.txt is available in, stopping search engine bots from crawling these pages.
In the event you don’t do this, Google might attempt to crawl an infinite variety of URLs with totally different (even non-existent) search parameter values, causing spikes and a waste of crawl budget.
When To Use Robots.txt
As a normal rule, you must at all times ask why sure pages exist, and whether or not they have something value for search engines like google to crawl and index.
If we come from this precept, actually, we should always at all times block:
- URLs that comprise question parameters resembling:
- Inner search.
- Faceted navigation URLs created by filtering or sorting choices if they aren’t a part of URL construction and search engine optimization technique.
- Motion URLs like add to wishlist or add to cart.
- Personal components of the web site, like login pages.
- JavaScript information not related to web site content material or rendering, resembling monitoring scripts.
- Blocking scrapers and AI chatbots to stop them from utilizing your content material for his or her coaching functions.
Let’s dive into how you should utilize robots.txt for every case.
1. Block Inner Search Pages
The commonest and completely obligatory step is to dam inside search URLs from being crawled by Google and other search engines, as nearly each web site has an inside search performance.
On WordPress web sites, it’s often an “s” parameter, and the URL appears like this:
https://www.instance.com/?s=google
Gary Illyes from Google has repeatedly warned to dam “motion” URLs as they’ll trigger Googlebot to crawl them indefinitely even non-existent URLs with totally different combos.
Right here is the rule you should utilize in your robots.txt to dam such URLs from being crawled:
Consumer-agent: *
Disallow: *s=*
- The Consumer-agent: * line specifies that the rule applies to all net crawlers, together with Googlebot, Bingbot, and so on.
- The Disallow: *s=* line tells all crawlers to not crawl any URLs that comprise the question parameter “s=.” The wildcard “*” means it could possibly match any sequence of characters earlier than or after “s= .” Nevertheless, it won’t match URLs with uppercase “S” like “/?S=” since it’s case-sensitive.
Right here is an instance of a web site that managed to drastically scale back the crawling of non-existent inside search URLs after blocking them by way of robots.txt.

Observe that Google might index those blocked pages, however you don’t want to fret about them as they are going to be dropped over time.
2. Block Faceted Navigation URLs
Faceted navigation is an integral a part of each ecommerce web site. There might be instances the place faceted navigation is a part of an search engine optimization technique and geared toward rating for normal product searches.
For instance, Zalando makes use of faceted navigation URLs for shade choices to rank for normal product key phrases like “grey t-shirt.”
Nevertheless, generally, this isn’t the case, and filter parameters are used merely for filtering merchandise, creating dozens of pages with duplicate content material.
Technically, these parameters usually are not totally different from inside search parameters with one distinction as there could also be a number of parameters. You want to be sure you disallow all of them.
For instance, you probably have filters with the next parameters “sortby,” “shade,” and “worth,” it’s possible you’ll use this algorithm:
Consumer-agent: *
Disallow: *sortby=*
Disallow: *shade=*
Disallow: *worth=*
Primarily based in your particular case, there could also be extra parameters, and it’s possible you’ll want so as to add all of them.
What About UTM Parameters?
UTM parameters are used for monitoring functions.
As John Mueller said in his Reddit post, you don’t want to fret about URL parameters that hyperlink to your pages externally.

Simply be certain to dam any random parameters you employ internally and keep away from linking internally to these pages, e.g., linking out of your article pages to your search web page with a search question web page “https://www.instance.com/?s=google.”
3. Block PDF URLs
Let’s say you’ve gotten lots of PDF paperwork, resembling product guides, brochures, or downloadable papers, and also you don’t need them crawled.
Right here is an easy robots.txt rule that may block search engine bots from accessing these paperwork:
Consumer-agent: *
Disallow: /*.pdf$
The “Disallow: /*.pdf$” line tells crawlers to not crawl any URLs that finish with .pdf.
By utilizing /*, the rule matches any path on the web site. Because of this, any URL ending with .pdf will probably be blocked from crawling.
If in case you have a WordPress web site and need to disallow PDFs from the uploads listing the place you add them by way of the CMS, you should utilize the next rule:
Consumer-agent: *
Disallow: /wp-content/uploads/*.pdf$
Permit: /wp-content/uploads/2024/09/allowed-document.pdf$
You’ll be able to see that we’ve got conflicting guidelines right here.
In case of conflicting guidelines, the more specific one takes precedence, which suggests the final line ensures that solely the precise file situated in folder “wp-content/uploads/2024/09/allowed-document.pdf” is allowed to be crawled.
4. Block A Listing
Let’s say you’ve gotten an API endpoint the place you submit your information from the shape. It’s possible your kind has an motion attribute like motion=”/kind/submissions/.”
The difficulty is that Google will attempt to crawl that URL, /kind/submissions/, which you possible don’t need. You’ll be able to block these URLs from being crawled with this rule:
Consumer-agent: *
Disallow: /kind/
By specifying a listing within the Disallow rule, you’re telling the crawlers to keep away from crawling all pages underneath that listing, and also you don’t want to make use of the (*) wildcard anymore, like “/kind/*.”
Observe that you could at all times specify relative paths and by no means absolute URLs, like “https://www.instance.com/kind/” for Disallow and Permit directives.
Be cautious to keep away from malformed guidelines. For instance, utilizing /kind and not using a trailing slash may also match a web page /form-design-examples/, which can be a web page in your weblog that you simply need to index.
Learn: 8 Common Robots.txt Issues And How To Fix Them
5. Block Consumer Account URLs
If in case you have an ecommerce web site, you possible have directories that begin with “/myaccount/,” resembling “/myaccount/orders/” or “/myaccount/profile/.”
With the highest web page “/myaccount/” being a sign-in web page that you simply need to be listed and located by customers in search, it’s possible you’ll need to disallow the subpages from being crawled by Googlebot.
You should use the Disallow rule together with the Permit rule to dam every thing underneath the “/myaccount/” listing (besides the /myaccount/ web page).
Consumer-agent: *
Disallow: /myaccount/
Permit: /myaccount/$
And once more, since Google makes use of essentially the most particular rule, it can disallow every thing underneath the /myaccount/ listing however enable solely the /myaccount/ web page to be crawled.
Right here’s one other use case of mixing the Disallow and Permit guidelines: in case you’ve gotten your search underneath the /search/ listing and need it to be discovered and listed however block precise search URLs:
Consumer-agent: *
Disallow: /search/
Permit: /search/$
6. Block Non-Render Associated JavaScript Recordsdata
Each web site makes use of JavaScript, and lots of of those scripts usually are not associated to the rendering of content material, resembling monitoring scripts or these used for loading AdSense.
Googlebot can crawl and render a web site’s content material with out these scripts. Subsequently, blocking them is protected and really useful, because it saves requests and sources to fetch and parse them.
Beneath is a pattern line that’s disallowing pattern JavaScript, which incorporates monitoring pixels.
Consumer-agent: *
Disallow: /property/js/pixels.js
7. Block AI Chatbots And Scrapers
Many publishers are involved that their content material is being unfairly used to train AI fashions with out their consent, and so they want to forestall this.
#ai chatbots
Consumer-agent: GPTBot
Consumer-agent: ChatGPT-Consumer
Consumer-agent: Claude-Net
Consumer-agent: ClaudeBot
Consumer-agent: anthropic-ai
Consumer-agent: cohere-ai
Consumer-agent: Bytespider
Consumer-agent: Google-Prolonged
Consumer-Agent: PerplexityBot
Consumer-agent: Applebot-Prolonged
Consumer-agent: Diffbot
Consumer-agent: PerplexityBot
Disallow: /
#scrapers
Consumer-agent: Scrapy
Consumer-agent: magpie-crawler
Consumer-agent: CCBot
Consumer-Agent: omgili
Consumer-Agent: omgilibot
Consumer-agent: Node/simplecrawler
Disallow: /
Right here, every consumer agent is listed individually, and the rule Disallow: / tells these bots to not crawl any a part of the positioning.
This, moreover stopping AI coaching in your content material, can assist scale back the load in your server by minimizing pointless crawling.
For concepts on which bots to dam, it’s possible you’ll need to examine your server log files to see which crawlers are exhausting your servers, and keep in mind, robots.txt doesn’t prevent unauthorized entry.
8. Specify Sitemaps URLs
Together with your sitemap URL within the robots.txt file helps search engines like google simply uncover all of the essential pages in your web site. That is finished by including a selected line that factors to your sitemap location, and you’ll specify a number of sitemaps, every by itself line.
Sitemap: https://www.instance.com/sitemap/articles.xml
Sitemap: https://www.instance.com/sitemap/information.xml
Sitemap: https://www.instance.com/sitemap/video.xml
In contrast to Permit or Disallow guidelines, which permit solely a relative path, the Sitemap directive requires a full, absolute URL to point the placement of the sitemap.
Make sure the sitemaps’ URLs are accessible to search engines like google and have correct syntax to keep away from errors.

9. When To Use Crawl-Delay
The crawl-delay directive in robots.txt specifies the variety of seconds a bot ought to wait earlier than crawling the following web page. Whereas Googlebot doesn’t acknowledge the crawl-delay directive, different bots might respect it.
It helps forestall server overload by controlling how regularly bots crawl your website.
For instance, if you would like ClaudeBot to crawl your content material for AI coaching however need to keep away from server overload, you’ll be able to set a crawl delay to handle the interval between requests.
Consumer-agent: ClaudeBot
Crawl-delay: 60
This instructs the ClaudeBot consumer agent to attend 60 seconds between requests when crawling the web site.
After all, there could also be AI bots that don’t respect crawl delay directives. In that case, it’s possible you’ll want to make use of a web firewall to charge restrict them.
Troubleshooting Robots.txt
When you’ve composed your robots.txt, you should utilize these instruments to troubleshoot if the syntax is appropriate or for those who didn’t by chance block an essential URL.
1. Google Search Console Robots.txt Validator
When you’ve up to date your robots.txt, you could examine whether or not it incorporates any error or by chance blocks URLs you need to be crawled, resembling sources, photographs, or web site sections.
Navigate Settings > robots.txt, and one can find the built-in robots.txt validator. Beneath is the video of tips on how to fetch and validate your robots.txt.
2. Google Robots.txt Parser
This parser is official Google’s robots.txt parser which is utilized in Search Console.
It requires superior expertise to put in and run in your native laptop. However it’s extremely really useful to take time and do it as instructed on that web page as a result of you’ll be able to validate your modifications within the robots.txt file earlier than importing to your server consistent with the official Google parser.
Centralized Robots.txt Administration
Every area and subdomain should have its personal robots.txt, as Googlebot doesn’t acknowledge root area robots.txt for a subdomain.
It creates challenges when you’ve gotten a web site with a dozen subdomains, because it means you must preserve a bunch of robots.txt information individually.
Nevertheless, it’s attainable to host a robots.txt file on a subdomain, resembling https://cdn.instance.com/robots.txt, and arrange a redirect from https://www.instance.com/robots.txt to it.
You are able to do vice versa and host it solely underneath the foundation area and redirect from subdomains to the foundation.
Search engines like google will deal with the redirected file as if it had been situated on the foundation area. This method permits centralized administration of robots.txt guidelines for each your essential area and subdomains.
It helps make updates and upkeep extra environment friendly. In any other case, you would wish to make use of a separate robots.txt file for every subdomain.
Conclusion
A correctly optimized robots.txt file is essential for managing a website’s crawl budget. It ensures that search engines like google like Googlebot spend their time on beneficial pages reasonably than losing sources on pointless ones.
However, blocking AI bots and scrapers utilizing robots.txt can considerably scale back server load and save computing sources.
Ensure you at all times validate your modifications to keep away from sudden crawability points.
Nevertheless, do not forget that whereas blocking unimportant sources by way of robots.txt might assist improve crawl effectivity, the principle components affecting crawl funds are high-quality content material and web page loading pace.
Glad crawling!
Extra sources:
Featured Picture: BestForBest/Shutterstock