Copy-Ready Robots.txt Examples by Platform
Finding a clean robots.txt example that actually fits your website platform saves hours of guesswork. A single mistyped slash in this plain-text file can accidentally tell search engines to stay away from your entire site, while leaving out key crawl exclusions lets bots spend time on admin screens and empty search pages.
If you want to skip manual editing altogether, you can build a valid file in your browser using our free robots.txt generator. And if you are brand new to how crawl files work from scratch, start with our step-by-step walkthrough on how to create a robots.txt file for SEO.
This guide focuses purely on practical robots.txt template snippets you can copy today—including core setups, WordPress, Shopify, and Next.js—plus how to test your live file safely.
Robots.txt Basics in 30 Seconds
Before copying any snippet, keep six essential rules in mind:
- User-agent: Names the crawler a group of rules applies to. Using
*means the rule applies to all compliant crawlers that do not have a more specific group. - Disallow: Tells compliant bots not to request a URL path starting with that string.
- Allow: Creates an exception inside an otherwise disallowed folder (supported by major crawlers such as Googlebot).
- Sitemap: Gives crawlers the full, absolute URL (starting with
https://) of your XML sitemap. - Root location: The file must be placed at the exact root of your domain (
https://yourdomain.com/robots.txt) in lowercase. Files placed in a subfolder are ignored. - Case-sensitive paths:
/Admin/and/admin/are treated as different paths. Match your site's real URL casing.
Three Copy-Ready Robots.txt Templates
These three baseline examples cover most simple websites and staging setups.
1. Robots.txt Allow All (Default Open Site)
Use this robots.txt allow all setup if you run a small blog, portfolio, or company website with no private folders or duplicate search URLs to hide.
User-agent: *
Allow: /
Sitemap: https://yourdomain.com/sitemap.xmlLeaving Disallow: empty also allows crawling. Adding Allow: / makes the intent explicit, and pointing to your sitemap helps crawlers discover pages efficiently.
2. Robots.txt Disallow All (Staging or Development Sites)
Use this robots.txt disallow all file only on test, staging, or pre-launch environments that are not ready for search engines.
User-agent: *
Disallow: /Never copy this rule onto a live production site. Also remember that a robots.txt rule is not password protection—protect confidential staging environments with HTTP authentication or a login screen.
3. Block One Folder and Declare Your Sitemap
If you want search crawlers to index your public site while skipping a temporary directory or internal test area, block just that path:
User-agent: *
Disallow: /private/
Sitemap: https://yourdomain.com/sitemap.xmlReplace /private/ with the exact folder path you want bots to avoid, and swap yourdomain.com for your real domain. You can also test custom folder combinations in our robots.txt generator before uploading.
Robots.txt for WordPress
A clean robots.txt for WordPress keeps backend dashboard URLs and internal site-search query pages out of search crawls, while keeping front-end scripts accessible so Google can render your theme layout properly.
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /?s=
Disallow: /search/
Sitemap: https://yourdomain.com/wp-sitemap.xmlNotice two important details when learning how to edit robots.txt in WordPress:
- Keep
admin-ajax.phpallowed: Many WordPress themes and plugins rely on/wp-admin/admin-ajax.phpto load interactive elements. Allowing it inside/wp-admin/prevents rendering issues. Do not block/wp-content/or/wp-includes/, as crawlers need your CSS and JavaScript files to view your pages accurately. - Check your real sitemap URL: Core WordPress creates
/wp-sitemap.xmlby default, whereas SEO plugins such as Yoast SEO or Rank Math typically generate/sitemap_index.xml. Those same SEO plugins also include built-in file editors under their tools settings so you can edit your virtual robots.txt from the dashboard without touching FTP.
Robots.txt for Shopify
If you run an eCommerce store, you usually do not need to write a robots.txt for Shopify from scratch. Shopify automatically generates a default robots.txt file at the root of your store that already includes standard exclusions for areas like /admin, /cart, /checkout, /orders, customer accounts, and common sorted or filtered collection URLs.
If your store requires custom crawl rules—for instance, blocking specific app-generated URL parameters—Shopify lets you customize the output through a robots.txt.liquid theme template inside your theme editor (Online Store → Themes → Edit code → Add a new template → robots.txt).
Because Shopify updates its default preset rules and Liquid template syntax periodically, verify the current template structure directly against Shopify's official Help Center documentation before editing robots.txt.liquid. Keep Shopify's default preset loop intact and only append or remove targeted rules; breaking the Liquid template can accidentally block your entire storefront.
Robots.txt for Next.js
If you build modern web apps, setting up robots.txt for Next.js is clean and code-driven. When using the Next.js App Router, you have two built-in options depending on whether you need dynamic URLs.
Option A: Dynamic app/robots.ts (Recommended)
To add robots.txt in Next.js App Router, create an app/robots.ts file using Next.js's built-in MetadataRoute.Robots type. Next.js automatically compiles it and serves valid plain text at /robots.txt:
import type { MetadataRoute } from 'next'
export default function robots(): MetadataRoute.Robots {
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://yourdomain.com'
return {
rules: {
userAgent: '*',
allow: '/',
disallow: ['/api/', '/admin/'],
},
sitemap: `${baseUrl}/sitemap.xml`,
}
}Using an environment variable like NEXT_PUBLIC_SITE_URL makes it easy to point staging deployments to one domain and production to another without hardcoding URLs.
Option B: Static public/robots.txt
If your rules never change across environments, create a plain-text file at public/robots.txt with standard directives:
User-agent: *
Allow: /
Disallow: /api/
Sitemap: https://yourdomain.com/sitemap.xmlDo not keep both app/robots.ts and public/robots.txt in the same Next.js project, as having both can cause route conflicts.
How to Check Your Live Robots.txt File
After publishing or updating your file, always verify that crawlers can fetch it cleanly:
- Open
/robots.txtin your browser: Visithttps://yourdomain.com/robots.txtdirectly. Confirm it loads with HTTP 200 as plain text, not an HTML 404 error page or login redirect. - Inspect the Google Search Console robots.txt report: Open Search Console, select your property, and go to Settings → robots.txt. Check when Googlebot last fetched the file and confirm there are zero syntax warnings.
- Test important URLs: Paste your homepage, key blog posts, or product pages into Search Console's URL Inspection tool and verify that crawling is allowed for the pages you want indexed.
What Robots.txt Does Not Do
Understanding the limits of robots.txt prevents painful indexing mistakes:
- It is not a security barrier: Your
robots.txtfile is completely public. Anyone can open/robots.txtand see which paths you disallowed. Never list secret admin URLs or confidential directories there; use proper authentication instead. - It does not guarantee de-indexing: A
Disallowline stops compliant crawlers from requesting the page, not from listing the URL in search results if other pages link to it. - Use
noindexwhen removing pages: If you want a page kept out of Google Search results, you must allow crawlers to visit the page so they can read a<meta name="robots" content="noindex">tag orX-Robots-Tag: noindexHTTP header. Blocking the URL inrobots.txthides thatnoindexinstruction from crawlers.
Common Mistakes and Next Steps
- Leaving
Disallow: /live after launch: Always check/robots.txtimmediately after moving a site from staging to production. - Forgetting trailing slashes: Writing
Disallow: /tagalso blocks/tags-guide/or/tagline. WriteDisallow: /tag/when you only want to block a folder. - Blocking CSS and JavaScript folders: Crawlers render pages visually to understand layout and mobile usability. Keep static asset folders crawlable.
- Using a relative
Sitemap:URL: Always write the fullhttps://address on the robots.txt sitemap line, not/sitemap.xml. - Relying on
Crawl-delayfor Google: Google ignores theCrawl-delaydirective inrobots.txt. Manage server load through hosting optimization or Search Console settings where available.
Ready to build your own rules without worrying about formatting? Try our free robots.txt generator, choose your options, preview the output, and download a ready-to-upload file in seconds. You can also explore our full suite of utilities in our SEO tools category.
Summary: Keep your rules short, verify your robots.txt sitemap line matches your real domain, check your live file in Search Console, and never block CSS, JavaScript, or pages carrying a noindex tag.
