Free tutorials & notes in Hindi & English · Clean code examples 🧰 मुफ़्त PDF और फ़ोटो टूल्स →
Guide 60 · SEO & Website Basics · Hindi + English

Beginners के लिए Robots.txt Basics

Website के कौन से parts search engines crawl कर सकते हैं, इसे control करें.

What robots.txt does

robots.txt is a plain text file at the root of a site (https://example.com/robots.txt) that tells search-engine crawlers which paths they may or may not crawl. It is a request, not a lock: well-behaved bots follow it, bad bots ignore it, and anyone can read the file.

Do not use robots.txt to hide private files – listing /admin-backup/ there actually advertises it. Protect private areas with passwords/server rules.

Syntax with a real example

User-agent: *
Disallow: /admin/
Disallow: /search/
Disallow: /cart/
Allow: /

Sitemap: https://example.com/sitemap.xml
LineMeaning
User-agent: *Rules for all crawlers (or name one, e.g. Googlebot)
Disallow: /admin/Do not crawl URLs starting with /admin/
Allow: /Everything else may be crawled
Sitemap:Full URL of your sitemap (see sitemaps)
* and $ in pathsWildcard and end-of-URL, e.g. Disallow: /*?sort=, Disallow: /*.pdf$

Disallow is not noindex

Blocking a URL in robots.txt stops crawling, but Google can still index the bare URL if other sites link to it (shown without a description). To keep a page out of search results, allow crawling and add <meta name="robots" content="noindex"> to the page (or an X-Robots-Tag: noindex header). Never block a page in robots.txt that you want Google to see the noindex on.

Costly mistakes

MistakeResult
Disallow: / left from a staging siteThe whole site disappears from Google over time
Blocking /assets/ or CSS/JS filesGoogle cannot render pages properly; mobile-friendliness suffers
Blocking pages that have noindexGoogle never sees the noindex
Typos: Disalow, missing slashRule ignored
robots.txt returning 5xx errorsGoogle may pause crawling the site

Test before and after changes

  • Open yourdomain.com/robots.txt in a browser – it must load as plain text with status 200.
  • Google Search Console → Settings → robots.txt report shows the version Google fetched and any errors.
  • Use URL Inspection on an important page to confirm “Crawl allowed: Yes”.
  • Python users can test rules with urllib.robotparser – see our web scraping lesson.

robots.txt क्या करता है

robots.txt site के root (https://example.com/robots.txt) पर रखी सादी text file है जो search-engine crawlers को बताती है कि कौन से paths crawl कर सकते हैं या नहीं। यह अनुरोध है, ताला नहीं: अच्छे bots मानते हैं, बुरे bots नज़रअंदाज़ करते हैं, और कोई भी file पढ़ सकता है।

निजी files छिपाने के लिए robots.txt इस्तेमाल न करें – वहाँ /admin-backup/ लिखना असल में उसका प्रचार करता है। निजी हिस्सों को passwords/server rules से बचाएँ।

असली उदाहरण के साथ syntax

User-agent: *
Disallow: /admin/
Disallow: /search/
Disallow: /cart/
Allow: /

Sitemap: https://example.com/sitemap.xml
Lineअर्थ
User-agent: *सभी crawlers के लिए नियम (या किसी एक का नाम, जैसे Googlebot)
Disallow: /admin//admin/ से शुरू होने वाले URLs crawl न करें
Allow: /बाक़ी सब crawl हो सकता है
Sitemap:आपके sitemap का पूरा URL (sitemaps देखें)
Paths में * और $Wildcard और URL का अंत, जैसे Disallow: /*?sort=, Disallow: /*.pdf$

Disallow, noindex नहीं है

robots.txt में URL block करने से crawling रुकती है, पर दूसरी sites link करें तो Google बिना description के URL index कर सकता है। Page को search results से बाहर रखने के लिए crawling allow करें और page में <meta name="robots" content="noindex"> (या X-Robots-Tag: noindex header) लगाएँ। जिस page का noindex Google को दिखाना है उसे robots.txt में block न करें।

महँगी ग़लतियाँ

ग़लतीनतीजा
Staging site से बचा Disallow: /समय के साथ पूरी site Google से गायब
/assets/ या CSS/JS files block करनाGoogle pages ठीक से render नहीं कर पाता; mobile-friendliness पर असर
noindex वाले pages block करनाGoogle को noindex दिखता ही नहीं
Typos: Disalow, slash छूटानियम नज़रअंदाज़
robots.txt का 5xx errors देनाGoogle site की crawling रोक सकता है

बदलाव से पहले और बाद जाँचें

  • Browser में yourdomain.com/robots.txt खोलें – status 200 के साथ सादे text में load होनी चाहिए।
  • Google Search Console → Settings → robots.txt report Google का लाया version और errors दिखाता है।
  • किसी ज़रूरी page पर URL Inspection से “Crawl allowed: Yes” पक्का करें।
  • Python users urllib.robotparser से नियम test कर सकते हैं – हमारा web scraping lesson देखें।

अक्सर पूछे जाने वाले सवाल

क्या robots.txt page को Google से हटाता है?

नहीं। यह सिर्फ़ crawling रोकता है। Results से हटाने के लिए noindex meta tag (crawling allow करके), 404/410 से delete, या तुरंत अस्थायी हटाने के लिए Search Console का Removals tool।

robots.txt कहाँ रखनी चाहिए?

Host के root में: https://example.com/robots.txt। Sub-folder की file नज़रअंदाज़ होती है। हर subdomain की अपनी file चाहिए।

क्या CSS और JavaScript block करूँ?

नहीं। Google को pages render और समझने के लिए इनकी ज़रूरत है। सिर्फ़ admin, cart और internal search जैसे निजी या बेकार crawl paths block करें।

यह lesson कैसा लगा?

आपकी राय से हम content और बेहतर बनाते हैं।

अपना review और सुझाव लिखें (वैकल्पिक)

Review approve होने के बाद आपका नाम और शहर इसके साथ public दिख सकते हैं। Email या phone न लिखें।

▶ CodingEasily on YouTube

Video से सीखें – आसान Hindi में

चुनी हुई video: RDBMS भाग 3 – Class XI Commerce IT

▶ Channel subscribe करें