Custom Routes

Add SEO support to custom Statamic or Laravel routes without reinventing the SEO implementation.

Seo::data()

Use the Seo::data() fluent builder to add SEO metadata to custom routes:

use Aerni\AdvancedSeo\Facades\Seo;

Route::statamic('/login', 'login', [
    'title' => 'Login',
    ...Seo::data()
        ->title('Login')
        ->description('Welcome back! Login to your account.')
        ->toArray(),
]);

This also works with regular Laravel routes:

Route::get('/login', function () {
    return view('login', [
        'title' => 'Login',
        ...Seo::data()
            ->title('Login')
            ->description('Welcome back! Login to your account.')
            ->toArray(),
    ]);
});

Available Methods

Method
Description

title(string)

Set the meta title.

description(string)

Set the meta description.

ogTitle(string)

Set the Open Graph title.

ogDescription(string)

Set the Open Graph description.

ogImage(string|Asset)

Set the Open Graph image. Accepts a URL or Statamic Asset.

noindex()

Mark the page as noindex.

nofollow()

Mark the page as nofollow.

canonicalUrl(string)

Set a custom canonical URL.

jsonLd(string|Type)

Set JSON-LD structured data. Accepts a raw JSON string or a Spatie\SchemaOrg\Type instance.

Last updated