New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

spatie/laravel-robots-middleware

Add an `all` or `none` robots header to your requests via a middleware in Laravel
2,550,320 333

Larablocks Analysis

Compatibility

Trusted maintainer

spatie/laravel-robots-middleware works with Laravel 10 to 13 (latest release 1.4.2, Feb 21, 2026).

Laravel 5 to 9 in earlier releases.

  • Trusted maintainer: spatie publishes 287 packages on Larablocks, with 204,800,870 downloads a month between them.

Recommendation checks

Recommended

Recommended by Larablocks: meets all 4 checks.

  • Works with Laravel 13, the current version
  • Released in the last 12 months (Feb 21, 2026)
  • 62,062 downloads a month (at least 10,000)
  • 333 GitHub stars (at least 100)

State

Maintained
  • Last stable release: Feb 21, 2026.
  • 1 release in the last 12 months.
  • First released: Jan 5, 2016.
  • Monthly downloads: 62,062, up 17% from six months ago.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 30, 2026.

Install
composer require spatie/laravel-robots-middleware
Latest Version:1.4.2
PHP:^8.2
Laravel:10 – 13
Older releases:5 – 9
License:MIT
Last Updated:Nov 5, 2026
Links: GitHub  ·  Packagist
Maintainer: spatie

Enable or disable the indexing of your app

Latest Version on Packagist run-tests Check & fix styling Total Downloads

A tiny, opinionated package to enable or disable indexing your site via a middleware in Laravel.

More on the Robots meta tag: https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

$ composer require spatie/laravel-robots-middleware

Usage

By default, the middleware enables indexing on all pages. You'll probably want to inherit your own class containing you application's indexing rule handler.

// app/Http/Middleware/MyRobotsMiddleware.php
namespace App\Http\Middleware;

use Illuminate\Http\Request;
use Spatie\RobotsMiddleware\RobotsMiddleware;

class MyRobotsMiddleware extends RobotsMiddleware
{
    /**
     * @return string|bool
     */
    protected function shouldIndex(Request $request)
    {
        return $request->segment(1) !== 'admin';
    }
}

Next, simply register the newly created class in your middleware stack.

// app/Http/Kernel.php

class Kernel extends HttpKernel
{
    protected $middleware = [
        // ...
        \App\Http\Middleware\MyRobotsMiddleware::class,
    ];
    
    // ...
}

That's it! Responses will now always have an x-robots-tag in their headers, containing an all or none value.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details. Due to nature of this package, there's a fair chance features won't be accepted to keep it light and opinionated.

Security

If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

spatie/elasticsearch-search-string-parser

Build Elasticsearch queries based of a query string

24,626 51
calotype/seo

A package containing SEO helpers.

2,650 73
exa2040/laravel-seo

A SEO extension for your laravel project.

12 0
seo
spatie/backtrace

A better backtrace

220,267,784 438
spatie/laravel-package-tools

Tools for creating Laravel packages

208,094,001 952

Version History

Version Released PHP Laravel License
1.4.2 ^8.2 ^10|^11.0|^12.0|^13.0 MIT
1.4.1 ^8.2 ^10|^11.0|^12.0 MIT
1.4.0 ^8.2 ^10|^11.0 MIT
1.3.2 ^7.2|^8.0 ^8.0|^9.0|^10 MIT
1.3.1 ^7.2|^8.0 ^8.0|^9.0 MIT