A custom website is a description of how your site was built, not where it runs. So there is no single place to edit robots.txt, and no single set of clicks that works for everyone. The method follows your hosting. Work out which hosting layer you use first, then edit the file that is actually served at the robots.txt address, not just any file with that name in your project.
Find the file that crawlers actually receive
Hand-built sites hide one extra step that platform sites do not. A robots.txt sitting in your code repository means nothing on its own. If your router or build pipeline never delivers it to the public address, crawlers never see it.
How delivery works depends on the layer.
On a static host such as Netlify, Vercel, or Cloudflare Pages, robots.txt is a static file in the publish directory of your repository, the same directory that holds the built index page. It ships with the site on deploy. Change the file and redeploy, and the new rules go live. Skip the redeploy and nothing changes.
Single-page apps carry a classic trap. A catch-all route that rewrites every request to the app shell can swallow the robots.txt request too, handing crawlers your app page instead of rules. The robots.txt file must be served before that catch-all in your routing order.
A platform-as-a-service gives you no shared folder for static files. Render, Fly.io, and Heroku all work this way. Serve robots.txt from your app code or your static middleware, as one more route the app owns.
On a virtual private server or a dedicated machine you manage yourself, the site is effectively self-hosted. The file lives in the document root of the web server, and you edit it there directly.
The steps
Start by checking the live address. Open yourdomain.com/robots.txt in a browser, using your real domain. If you receive your app shell, a 404, or an HTML page, the request is not reaching a robots.txt file at all. That result itself tells you where to look.
Everything below depends on one answer: what kind of hosting runs your site? A static host, a platform-as-a-service, or a server of your own?
On a static host, the file goes in the publish directory, beside the built index page. Add or edit it there, commit, redeploy, and reload the address to confirm.
With a single-page app, routing order decides everything. The robots.txt address must be served as a static file ahead of the catch-all rewrite to the app shell. If the rewrite fires first, the file stays hidden, however correct it is.
On a platform-as-a-service, the app itself has to answer. Add a route or static middleware that returns the file at the robots.txt address with a text/plain content type. Deploy, then check it loads.
For your own server, edit the file in the document root of the web server.
Wherever the file lives, add the AI crawler groups high in the file, ahead of any broad block rules:
User-agent: OAI-SearchBot
Allow: /
User-agent: ChatGPT-User
Allow: /
User-agent: Claude-SearchBot
Allow: /
User-agent: Claude-User
Allow: /
User-agent: PerplexityBot
Allow: /
User-agent: meta-webindexer
Allow: /
User-agent: bingbot
Allow: /
One limit to know: ChatGPT-User only shows up when a person asks ChatGPT to look at a page. Your allow line gives it permission, but it cannot steer a fetcher that pays no attention to robots.txt.
Finally, verify from the outside. Reload yourdomain.com/robots.txt and confirm the groups are present with the right content type. What your repository contains and what the address serves are two different facts, and only the second one matters to crawlers.
The file that never made it into the build
Imagine a consulting business with a marketing site built by a static generator and deployed on a static host. The developer adds robots.txt to the root of the repository, where the source files live, and pushes the change. The address still returns a 404. The publish directory holds build output, so the file had missed the build entirely. Moving it next to the built index page and redeploying fixed the problem in one deploy.
On a custom site, the question is never simply whether you wrote the file. It is whether the file reached the public address.
The file alone is not the whole story
Robots.txt states what you intend. It cannot force a result. If a bot manager or a content delivery network stops an AI crawler before it reads the file, your allow rules never get a chance to matter. Checking that outer layer, and keeping an eye on it over time, sits outside this edit.
Frequently Asked Questions
I added robots.txt to my repository, but the address returns a 404. Why?
Because the file never made it into the build. On static hosts it must sit in the publish directory, next to the built index page, and it only goes live when you redeploy.
My single-page app returns the app shell for the robots.txt address. What is wrong?
Your routing order is the problem. A catch-all rewrite to the app shell is swallowing the request. Serve the robots.txt address as a static file before the catch-all.
I run on a platform-as-a-service. Where does the file go?
No shared static directory exists on these platforms. The file has to come from your app code or static middleware, served as one more route the app owns.
How do I confirm the file is really live?
Reload the address from outside your project and confirm the groups are present with the right content type. What your repository holds and what the address serves are two different facts.
Verified Sources & Technical Documentation
- RFC 9309, Robots Exclusion Protocol Specific https://www.rfc-editor.org/rfc/rfc9309.html
- Cloudflare bot solutions docs, verified bots General Docs https://developers.cloudflare.com/bots/concepts/bot/verified-bots/
links marked specific point to the page that supports the claim in this guide. Links marked general docs point to the vendor's general docs section for that topic, not to a page that proves every step. Check the vendor docs for the current path before relying on a menu name or click path in this guide.