How to create a robots.txt file for your website
A robots.txt file is a small plain text file at yourdomain.com/robots.txt that tells search engines which parts of your site to crawl. To create one, make a text file named robots.txt, add a few lines, and upload it to the top level of your site.
If you type yourdomain.com/robots.txt into your browser and see a "page not found" error, your site has no robots.txt file. This is very common, and it is usually not an emergency. When the file is missing, Google treats it as "no restrictions" and crawls whatever it can find.
Still, having the file is good practice, it takes about ten minutes, and it gives you a place to point search engines to your sitemap and keep them out of pages that have no value in search results.
What the problem looks like
You will not see anything wrong on your website itself. The problem only shows up when you or a tool request the file directly. Typical signs:
- Visiting
/robots.txtshows a 404 or "page not found" message. - Visiting it shows your normal home page or a designed error page instead of plain text (some sites do this by mistake, so the file is effectively missing).
- An SEO review or Google Search Console reports that the file could not be found.
Why it matters
A missing file is not a penalty, but it costs you some control:
- Sitemap discovery: you can list your sitemap address in robots.txt so crawlers find it without being told.
- Wasted crawling: search engines may spend time on internal search results, cart and checkout pages, login pages or filtered product lists. On a small site this rarely hurts. On a larger shop it can slow down how quickly your important pages are visited.
- Server load: unrestricted crawlers can add traffic to a small hosting plan.
- Tidiness and trust: a missing file is one of the first things an SEO audit flags, and fixing it removes a distraction from the issues that matter more.
One honest warning: robots.txt is not a security tool. It is a polite request, and anyone can read the file. Never use it to hide private pages or list secret addresses. Protect those with a password or login instead.
How to check if your site has the problem
All of these are free:
- Open a browser and go to
https://yourdomain.com/robots.txt(use your real domain). You should see a few lines of plain text. - If you see an error, a blank page or your home page, the file is missing or wrong.
- If you use Google Search Console, open Settings and look for the robots.txt report. It shows whether Google could fetch the file.
- Technical users can run
curl -I https://yourdomain.com/robots.txtand look for200(found) or404(missing). The content type should betext/plain.
Remember that every subdomain needs its own file. shop.yourdomain.com does not use the file from yourdomain.com.
How to fix it in general
The file must be named exactly robots.txt (lowercase), saved as plain text with UTF-8 encoding, and placed at the root of the site. A file in a subfolder is ignored.
A safe starting point for most sites looks like this:
User-agent: *
Disallow:
Sitemap: https://www.yourdomain.com/sitemap.xml
What the lines mean:
User-agent: *means the rules apply to all crawlers.Disallow:with nothing after it means nothing is blocked.Sitemap:gives the full address of your sitemap. Use the real address and includehttps://.
If you want to keep crawlers out of certain areas, add one Disallow: line per path, for example Disallow: /cart/ or Disallow: /search/. Only block paths you are sure about.
Be very careful with Disallow: /. That single slash tells search engines to stay away from your entire site. If you already have this by accident, see robots.txt blocking your whole site.
To upload the file on traditional hosting, create it in a text editor such as Notepad (not Word), then use your host's File Manager or an FTP client to place it in the main web folder, often called public_html, www or htdocs. The name differs between hosts.
Platform notes
Many platforms create the file for you, so check before making your own. Menu names change between versions, so treat these as a guide.
- WordPress: it normally serves a basic virtual file on its own. If yours is missing, check Settings, Reading, and make sure "Discourage search engines from indexing this site" is off. Plugins such as Yoast SEO and Rank Math include a robots.txt editor. See the WordPress guide.
- Shopify: a file is generated automatically. You can customise it through the
robots.txt.liquidtemplate in your theme. See the Shopify guide. - Wix: a file is generated automatically, and recent versions let you edit it under the SEO tools section.
- Squarespace: the file is generated for you and generally cannot be edited directly.
- Webflow: look under Site settings, SEO, for a robots.txt field.
- Next.js: add a
robots.txtfile to thepublicfolder, or anapp/robots.tsfile in the App Router. - Magento: usually under Content, Design, Configuration, then the Search Engine Robots setting.
If your platform builds the file automatically and you still get a 404, the cause is often a redirect, a caching layer or a server rule. Ask your host or developer to look at it.
How to confirm the fix worked
- Load
https://yourdomain.com/robots.txtin a private browser window. You should see your plain text lines, not a design. - Check that the sitemap address in the file opens correctly when you click it.
- In Google Search Console, open the robots.txt report and request a recrawl if the old version is still showing. It can take a little while to update.
- Use the URL Inspection tool on your home page and one important page to make sure neither is blocked.
How to stop it coming back
The file usually disappears during a redesign, a migration to a new host, or a move from a staging site to the live site. The opposite mistake is also common: a staging site's "block everything" file gets copied to the live site.
- Keep a copy of your working
robots.txtsomewhere safe, or in your code repository. - After any migration, redesign or platform change, open
/robots.txtas part of your launch checklist. - Recheck it every few months, especially if several people edit the site.
SiteMonday's week 1 SEO review looks at this file along with other basic search checks, so a missing or wrong file gets flagged and ranked in a fix list. Fixing it is still up to you or your developer.
Step by step for your platform
- Missing robots.txt file on WordPress
- Missing robots.txt file on Shopify
- Missing robots.txt file on Wix
- Missing robots.txt file on Squarespace
- Missing robots.txt file on Webflow
- Missing robots.txt file on Next.js
- Missing robots.txt file on Magento
Questions
Is a missing robots.txt file bad for SEO?
Not directly. Google treats a missing file as permission to crawl everything, so your pages can still be indexed. Having one just gives you more control and a clear place to list your sitemap.
Where does the robots.txt file go?
It must sit at the root of your domain, so it opens at `yourdomain.com/robots.txt`. A copy in a subfolder will be ignored, and each subdomain needs its own file.
Can robots.txt hide private pages?
No. The file is public and only asks well-behaved crawlers to stay away. Use a password or login for anything private.
What should a basic robots.txt contain?
A simple version has `User-agent: *`, an empty `Disallow:` line, and a `Sitemap:` line with your full sitemap address. Add specific `Disallow:` paths only if you have a clear reason.
Does robots.txt remove a page from Google?
Not reliably. It stops crawling, but a blocked page can still appear in results if other sites link to it. To keep a page out of search, use a `noindex` tag on a page that crawlers are allowed to visit.
How long until Google notices my new robots.txt?
Google usually rechecks the file within about a day, though it can vary. You can check the status in the Search Console robots.txt report.