T
ToolPrime

robots.txt for Gatsby Sites

robots.txt template for Gatsby static sites. Optimized for the static site generation build process.

robots.txt

User-agent: *
Disallow: /404
Disallow: /404.html
Disallow: /dev-404-page/
Allow: /

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

Line-by-Line Explanation

User-agent: * — applies to all crawlers

Disallow: /404 and /404.html — prevents the 404 page from being indexed

Disallow: /dev-404-page/ — blocks the Gatsby development 404 page

Allow: / — all other pages are freely crawlable (they are static HTML)

Sitemap — points to the Gatsby-generated sitemap index

Best Practices for Gatsby

Build a custom robots.txt for your Gatsby site

Open robots.txt Generator

Frequently Asked Questions

How do I add robots.txt to a Gatsby site?
Use gatsby-plugin-robots-txt (recommended) or place a robots.txt file in the /static directory. The plugin approach allows environment-specific configuration.
Does Gatsby need a complex robots.txt?
No. Since Gatsby generates static HTML, pages are easily crawlable. A minimal robots.txt blocking only error pages and including a sitemap is usually sufficient.
Should I block /page-data/ in Gatsby?
No. Gatsby uses /page-data/ for client-side navigation. Blocking it does not affect SEO since Google crawls the HTML pages directly, and blocking it could break preloading.

Related Templates