Skip to content

Tutorials Website building Beginner1 min read

How to Create a robots.txt File

Write a correct robots.txt: allow and disallow crawling, link your sitemap, avoid blocking CSS and JS, and test it before search engines read it.

By ZSOLNET Editorial Team Updated

Key takeaways

  • robots.txt tells crawlers which paths they may fetch.
  • Disallowing a page doesn't remove it from search — use noindex for that.
  • A single wrong line can hide your whole site from search engines.

A sensible default

User-agent: *
Disallow:

Sitemap: https://example.com/sitemap.xml

An empty Disallow: allows everything. The Sitemap line helps crawlers find your pages.

WordPress example

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php

Sitemap: https://example.com/wp-sitemap.xml

Rules to remember

  • Paths are case-sensitive and match by prefix: Disallow: /private also blocks /private-offers.
  • * matches any characters and $ anchors the end: Disallow: /*.pdf$.
  • Don’t block CSS, JavaScript or images — search engines need them to render pages.
  • Disallow: / blocks the whole site. Staging sites use it; production sites almost never should.

Create and test

  1. Generate a file with the robots.txt generator or write it by hand.
  2. Upload it to your site’s document root (public_html).
  3. Check it with the robots.txt checker and in Search Console’s robots.txt report.

Frequently asked questions

Where does robots.txt go?

At the root of the host: https://example.com/robots.txt. Each subdomain needs its own.

Can robots.txt keep private files secret?

No. It's public and only advisory. Protect private files with passwords or by not putting them on the public web server.

Share X LinkedIn Facebook

Log in to your account

Manage your domains, hosting and invoices in one place.

Secure connection straight to the ZSOLNET client area.

Open the ZSOLNET dashboard

No account yet?