Skip to content
Nazmul Nikhil
Menu

Robots.txt Has Syntax Error (Ahrefs): Fix Rules Crawlers Can't Read

Ahrefs flags robots.txt lines that crawlers can't understand. Invalid lines are ignored, which may not be what you intended. Here are the common mistakes.

Nazmul Nikhil

By

Head of SEO & Assistant Manager, Digital Marketing at Notionhive

Published 1 min read
Robots.txt Has Syntax Error (Ahrefs): Fix Rules Crawlers Can't Read
Photo: Franz Michael Schneeberger on Unsplash

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.

Sources and references

TAGSAhrefs Site AuditRobots.txt syntax errorRobots.txt errorsInvalid robots.txt
Nazmul Nikhil

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.

Need help with this?

Get it fixed with Technical SEO

I find the issues that cost you traffic and fix them, starting with the pages that matter most.

Keep reading

Related articles

All Site Audit Issues posts →

Get the next guide in your inbox

One email when a new SEO or AI search guide goes live.

Ready to grow?

Get a free audit of your website, or book a 30-minute call to talk through your goals.

Nazmul Hasan

Talk to Nazmul directly

Reply within 24h

WhatsApp +880 1682835118
nazmulnikhil@gmail.com