How do you write a robots.txt file?
SMSEOMİT Editorial Team·October 28, 2026·5 min read
The robots.txt file sits at the root of your domain and tells search engine and AI crawlers which folders they should crawl and which admin or cart pages they should skip.
What does robots.txt do?
Located at yourdomain.com/robots.txt, this plain-text file protects your crawl budget by keeping bots out of admin panels, checkout flows, and internal search result URLs so they focus on your core landing pages and articles.
Core directives
- User-agent: Specifies which crawler the rule applies to (
*means all crawlers). - Disallow: Blocks a directory or path (e.g.,
Disallow: /admin/). - Allow: Overrides a broader disallow rule for a specific subpath.
- Sitemap: Points crawlers to your XML sitemap URL.
Ideal robots.txt template
User-agent: *Allow: /Disallow: /admin/Disallow: /cart/Sitemap: https://yourdomain.com/sitemap.xml
You can generate a customized file in seconds with our free robots.txt Generator.
Want to boost your website's authority and visibility?Our SEO & GEO packages combine technical optimization, content, and high-authority backlinks with transparent one-time pricing.See packages
Common mistakes to avoid
Never block CSS or JS assets needed for mobile rendering, remember to remove staging Disallow: / rules upon launch, and make sure you do not accidentally block AI search bots like GPTBot or PerplexityBot.