Respecting robots.txt | crawler-go | Spatie       

 SPATIE  

crawler-go
==========

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Crawler-go](https://spatie.be/docs/crawler-go/v1)  Configuring-the-crawler  Respecting robots.txt

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/crawler-go/v1) 

  Respecting robots.txt    
- [ Introduction ](https://spatie.be/docs/crawler-go/v1/introduction)
- [ Installation &amp; setup ](https://spatie.be/docs/crawler-go/v1/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/crawler-go/v1/questions-issues)
- [ About us ](https://spatie.be/docs/crawler-go/v1/about-us)
- [ Releasing ](https://spatie.be/docs/crawler-go/v1/releasing)
- [ Changelog ](https://spatie.be/docs/crawler-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/crawler-go/v1/support-us)

Basic usage
-----------

- [ Your first crawl ](https://spatie.be/docs/crawler-go/v1/basic-usage/starting-your-first-crawl)
- [ Crawl responses ](https://spatie.be/docs/crawler-go/v1/basic-usage/handling-crawl-responses)
- [ Using observers ](https://spatie.be/docs/crawler-go/v1/basic-usage/using-observers)
- [ Collecting URLs ](https://spatie.be/docs/crawler-go/v1/basic-usage/collecting-urls)
- [ Filtering URLs ](https://spatie.be/docs/crawler-go/v1/basic-usage/filtering-urls)
- [ Testing ](https://spatie.be/docs/crawler-go/v1/basic-usage/testing)
- [ Tracking progress ](https://spatie.be/docs/crawler-go/v1/basic-usage/tracking-progress)

Configuring the crawler
-----------------------

- [ Concurrency &amp; throttling ](https://spatie.be/docs/crawler-go/v1/configuring-the-crawler/crawl-behavior)
- [ Limits ](https://spatie.be/docs/crawler-go/v1/configuring-the-crawler/setting-crawl-limits)
- [ Extracting resources ](https://spatie.be/docs/crawler-go/v1/configuring-the-crawler/extracting-resources)
- [ Configuring requests ](https://spatie.be/docs/crawler-go/v1/configuring-the-crawler/configuring-requests)
- [ Response filtering ](https://spatie.be/docs/crawler-go/v1/configuring-the-crawler/handling-responses)
- [ Respecting robots.txt ](https://spatie.be/docs/crawler-go/v1/configuring-the-crawler/respecting-robots-txt)

Advanced usage
--------------

- [ JavaScript rendering ](https://spatie.be/docs/crawler-go/v1/advanced-usage/rendering-javascript)
- [ Custom link extraction ](https://spatie.be/docs/crawler-go/v1/advanced-usage/extracting-custom-links)
- [ Custom request handlers ](https://spatie.be/docs/crawler-go/v1/advanced-usage/custom-request-handlers)
- [ Crawling across requests ](https://spatie.be/docs/crawler-go/v1/advanced-usage/crawling-across-requests)
- [ Custom crawl queue ](https://spatie.be/docs/crawler-go/v1/advanced-usage/using-a-custom-crawl-queue)
- [ Graceful shutdown ](https://spatie.be/docs/crawler-go/v1/advanced-usage/graceful-shutdown)

 Respecting robots.txt
=====================

###  On this page 

1. [ Ignoring robots rules ](#content-ignoring-robots-rules)
2. [ Accepting nofollow links ](#content-accepting-nofollow-links)
3. [ Custom user agent ](#content-custom-user-agent)
4. [ Fetching and document directives ](#content-fetching-and-document-directives)

By default, the crawler respects robots.txt, meta robots tags and X-Robots-Tag response headers. Parsing is done by [spatie/robots-txt-go](https://github.com/spatie/robots-txt-go).

Ignoring robots rules
-----------------------------------------------------------------------------------------------------------------------

Set `Config.IgnoreRobots = true` to disable robots.txt access checks and document noindex/nofollow enforcement. The default is false. This does not enable link-level rel=nofollow following, which has its own option.

Accepting nofollow links
--------------------------------------------------------------------------------------------------------------------------------

```
c.Parser = crawler.LinkParser{FollowNofollow: true}
```

The default link parser rejects rel attributes containing `nofollow`. Enabling link following does not override document-level nofollow when robots enforcement is enabled.

Custom user agent
-----------------------------------------------------------------------------------------------------------

`Config.UserAgent` defaults to `*`. `Headers.Set("User-Agent", value)` takes precedence for both HTTP requests and robots.txt decisions. Use the same identity that the website's user-agent-specific rules expect.

Fetching and document directives
--------------------------------------------------------------------------------------------------------------------------------------------------------

Robots.txt is cached per origin for one execution. It uses the configured HTTP client, headers and query defaults, but not page retries, observers, MIME filtering or JavaScript rendering. Reads are capped at 2 MiB. Like PHP, failed robots requests impose no rules, except context cancellation stops the crawl. Always-crawl rules bypass robots.txt.

Unlike PHP's single seed robots file, the Go crawler reads each scheduled origin's own robots.txt. Redirect hops and browser subresources do not receive separate robots checks. Crawl-delay is not used automatically. Configure a throttle explicitly.

Meta and header semantics follow the Robots TXT Go package. Generic document directives apply through its default `*` identity, matching PHP Crawler. Noindex suppresses successful notifications but can still contribute links. Nofollow suppresses discoveries. Empty or MIME-filtered bodies skip document directives, matching PHP.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
