Drupal robots.txt
Find Drupal's default robots.txt, make narrow crawl-rule changes, and confirm the file is served from the right domain root.
Drupal ships robots.txt at the web root. For one site, append your rules with Composer Scaffold so core updates don't overwrite them. Use the RobotsTxt module for multisite per-domain rules; its README says to delete or rename the root file so the module can serve /robots.txt. Test the public response. Crawl rules do not protect private pages or guarantee deindexing.
Where does your site stand?
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
- Free audit in 60 seconds
- Fixes drafted for your review
- ChatGPT, Perplexity, Gemini and AI Overviews tracked
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
- Re-check after big site changes
- Keep this page for reference
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
- Follow the steps below
- Top-traffic pages first
- Check again in a month
3 parts, 4 minutes.
Find the file Drupal actually serves
robots.txt belongs at the top-level directory of the host, usually beside the web root entry point. In Drupal core's file (main branch on api.drupal.org) there are Disallow rules for /admin/, /core/, /profiles/ and user routes such as /user/login, plus Allow rules for /core/*.css$, /core/*.js$ and image formats such as svg, png and webp. Inspect the deployed file before adding rules; a robots.txt under a subdirectory does not apply to the whole hostname.- 01
Request the production endpoint
Open
https://example.com/robots.txtfor every public hostname. Confirm a plain-text response and check that a CDN, reverse proxy, or subdirectory install is not serving a different file. - 02
Edit through the deployment source
For a typical single-site Drupal install, change the file in your code or deployment artifact, not a server copy that the next deployment will replace. If the site is built with Composer, Drupal's Composer Scaffold plugin overwrites scaffold files such as
robots.txtby default, so a hand edit can disappear on the next core update. Append your rules instead (example below). - 03
Retest critical assets and routes
Check the rule against an important page, its rendered CSS and JavaScript, and any sitemap path. Test with Search Console's robots.txt report or URL Inspection when a crawl issue is suspected.
Use the RobotsTxt module for a real multisite need
robots.txt must be deleted or renamed before the module can serve its own file. If the root file remains, the web server may return that static file before Drupal can handle the request.- 01Install the module only when sites sharing one codebase need different crawl instructions. Release 8.x-1.6 lists Drupal
^9.3 || ^10 || ^11as compatible; check the release feed for newer versions. - 02After enabling it, request
/robots.txton each domain and confirm each host gets the intended rules. - 03The module's own settings page is Configuration > Search and metadata > RobotsTxt. With Composer Scaffold, add
"[web-root]/robots.txt": falsetodrupal-scaffoldfile-mappingso core stops re-creating the static file. - 04If the module does not serve your file, its troubleshooting list asks whether you deleted or moved the webroot
robots.txt, whether clean URLs are disabled, and whether the fast 404 feature is enabled. - 05For one domain and one rule set, a maintained root file is usually the simpler solution.
Make a narrow rule and verify its effect
append directive is documented in the Composer Scaffold README, which also says to use append and prepend where possible. The path is relative to your project root.noindex directive; a blocked crawler cannot fetch that directive.Sitemap: with the absolute production sitemap URL if you want to expose it through robots.txt; make sure the sitemap is reachable and contains canonical URLs."extra": {
"drupal-scaffold": {
"file-mapping": {
"[web-root]/robots.txt": {
"append": "assets/my-robots-additions.txt"
}
}
}
}User-agent: *
Disallow: /internal-search/
Sitemap: https://www.example.com/sitemap.xmlThis is an example, not a Drupal default. Only disallow a path after confirming it exists and should not be fetched. Keep CSS, JavaScript, and image resources crawlable when Google needs them to render page content.
See Drupal's default robots.txt, the RobotsTxt module, Google's robots.txt introduction, and the noindex guide.
Every fact, linked and dated.
drupal.org
drupalcode.org
google.com
- 01robots.txt | Drupal APIapi.drupal.org · checked 2026-10-24
- 02RobotsTxt module README | Drupal.orggit.drupalcode.org · checked 2026-10-24
- 03Composer Scaffold README | Drupal coregit.drupalcode.org · checked 2026-10-24
- 04Introduction to robots.txt | Google Search Centraldevelopers.google.com · checked 2026-10-24
- 05How Google interprets the robots.txt specification | Google Search Centraldevelopers.google.com · checked 2026-10-24
Asked a lot.
3 questions people ask next, answered from the sources on this page.
01Where is robots.txt in Drupal?
It is served from the top-level path https://your-domain.example/robots.txt. Drupal core ships a robots.txt in the web root; check the public URL because a subdirectory copy or cached file may not be the one crawlers receive.
02How do I edit robots.txt for a Drupal multisite?
The contributed RobotsTxt module generates robots.txt dynamically and lets you edit it per site from the web UI. Its README says to delete or rename the root file, otherwise the web server serves the static file first. Then test every domain.
03Can robots.txt remove a Drupal page from Google?
No. A disallow rule controls crawling and does not guarantee deindexing. Let Google crawl a public page to read noindex, or require authentication for private content.
Tools point. Agencies advise. This one ships.
Run the free audit, then approve the fixes. Every change can be undone.
- 46 fixes shipped without a ticket Brightpipe
- 0→7 ChatGPT citations in six weeks Paylane