In short
Ahrefs flags "Robots.txt has syntax error" when your robots.txt contains lines that don't follow the robots.txt standard. Google ignores invalid lines and keeps the rest, so the file may block or allow more than you think. Common mistakes are rules without a User-agent line, unsupported directives like Noindex:, typos in field names, and paths that don't start with /.
Robots.txt is short and simple, which makes its mistakes easy to miss.
Common errors
| Error | Example | Fix |
|---|---|---|
| Rule before any User-agent | Disallow: /admin/ at the top |
Put a User-agent: line first |
| Unsupported directive | Noindex: /page/ |
Google ended support in 2019; use a meta robots tag |
| Typo | Dissallow: /tmp/ |
Disallow |
| Path without leading slash | Disallow: admin |
Disallow: /admin/ |
| Crawl-delay for Google | Crawl-delay: 10 |
Google ignores it; Bing supports it |
| HTML or other content in the file | A CMS error page served as robots.txt | Serve plain text |
A clean example
User-agent: *
Disallow: /admin/
Disallow: /api/
Sitemap: https://example.com/sitemap.xml
Note that paths are case-sensitive, and Disallow: with nothing after it allows everything.
Where to edit
WordPress: Yoast SEO > Tools > File editor, or Rank Math > General Settings > Edit robots.txt. A physical robots.txt file in the site root overrides both.
Shopify: the robots.txt.liquid theme template.
Webflow: Site settings > SEO > robots.txt.
Wix: the Robots.txt Editor in the SEO dashboard.
Custom builds: the robots.txt file at the site root. Test changes in Search Console's robots.txt report.
This guide isn't affiliated with or endorsed by Ahrefs.
Related issues
Sources and references
Google Search Central, How Google interprets the robots.txt specification
Google Search Central Blog, A note on unsupported rules in robots.txt (July 2019)

About the author
Nazmul Nikhil
Head of SEO & Assistant Manager, Digital Marketing at Notionhive
SEO and AI search consultant in Dhaka, Bangladesh, helping small and mid-size businesses in the USA, UK, Australia and Canada.



