All Projects → romanzipp → Laravel Seo

romanzipp / Laravel Seo

Licence: mit
SEO package made for maximum customization and flexibility

Projects that are alternatives of or similar to Laravel Seo

Seo Manager
Seo Manager Package for Laravel ( with Localization )
Stars: ✭ 192 (+47.69%)
Mutual labels:  laravel, seo
Seo Helper
🔍 SEO Helper is a package that provides tools and helpers for SEO (Search Engine Optimization).
Stars: ✭ 262 (+101.54%)
Mutual labels:  laravel, seo
Laravelmetatags
The most powerful and extendable tools for managing SEO Meta Tags in your Laravel project
Stars: ✭ 226 (+73.85%)
Mutual labels:  laravel, seo
Laravel Queue Monitor
Monitoring Laravel Jobs with your Database
Stars: ✭ 136 (+4.62%)
Mutual labels:  laravel, showcase
Lashop
Simple shop based on Laravel 7.3
Stars: ✭ 60 (-53.85%)
Mutual labels:  laravel, seo
Seotools
SEO Tools for Laravel
Stars: ✭ 2,406 (+1750.77%)
Mutual labels:  laravel, seo
Laravel Robots Middleware
Enable or disable the indexing of your app
Stars: ✭ 259 (+99.23%)
Mutual labels:  laravel, seo
Lara Head
Easily setup SEO in your laravel project with lara-head ❤️ @code4mk
Stars: ✭ 169 (+30%)
Mutual labels:  laravel, seo
Laravel Missing Page Redirector
Redirect missing pages in your Laravel application
Stars: ✭ 378 (+190.77%)
Mutual labels:  laravel, seo
Laravel Referer
Remember a visitor's original referer
Stars: ✭ 339 (+160.77%)
Mutual labels:  laravel, seo
Laravel Link Checker
Check all links in a Laravel application
Stars: ✭ 253 (+94.62%)
Mutual labels:  laravel, seo
Laravel Seo Tools
Laravel Seo package for Content writer/admin/web master who do not know programming but want to edit/update SEO tags from dashboard
Stars: ✭ 99 (-23.85%)
Mutual labels:  laravel, seo
Laravel Paginateroute
Laravel router extension to easily use Laravel's paginator without the query string
Stars: ✭ 306 (+135.38%)
Mutual labels:  laravel, seo
Laravel Sitemap
Create and generate sitemaps with ease
Stars: ✭ 1,325 (+919.23%)
Mutual labels:  laravel, seo
Open Graph
Library that assists in building Open Graph meta tags
Stars: ✭ 112 (-13.85%)
Mutual labels:  laravel, seo
React Next Boilerplate
🚀 A basis for reducing the configuration of your projects with nextJS, best development practices and popular libraries in the developer community.
Stars: ✭ 129 (-0.77%)
Mutual labels:  seo
Nova Settings Tool
Laravel Nova tool to view and edit application settings.
Stars: ✭ 131 (+0.77%)
Mutual labels:  laravel
Laravue Core
Laravel package to provide core functionalities of Laravue dashboard
Stars: ✭ 130 (+0%)
Mutual labels:  laravel
Laravel Database Schedule
Manage your Laravel Task Scheduling in a friendly interface and save schedules to the database.
Stars: ✭ 94 (-27.69%)
Mutual labels:  laravel
Eloquent Tree
Eloquent Tree is a tree model for Laravel Eloquent ORM.
Stars: ✭ 131 (+0.77%)
Mutual labels:  laravel

Laravel SEO

Latest Stable Version Total Downloads License GitHub Build Status

A SEO package made for maximum customization and flexibility.

Contents

Installation

composer require romanzipp/laravel-seo

Configuration

Copy configuration to config folder:

$ php artisan vendor:publish --provider="romanzipp\Seo\Providers\SeoServiceProvider"

Documentation

Usage

Instantiation

use romanzipp\Seo\Facades\Seo;
use romanzipp\Seo\Services\SeoService;

class IndexController
{
    public function index(Request $request, SeoService $seo)
    {
        $seo = seo();

        $seo = app(SeoService::class);

        $seo = Seo::make();
    }
}

Render

{{ seo()->render() }}

Examples

This package offers many ways of adding new elements (Structs) to your <head>.

  1. Add commonly used structs via shorthand setters like seo()->title('...'), seo()->meta('...')
  2. Manually add single structs via the seo()->add() methods
  3. Specify an array of contents via seo()->addFromArray()

Take a look at the structs documentation or example app for more detailed usage.

Title

seo()->title('Laravel');
<title>Laravel</title>
<meta property="og:title" content="Laravel" />
<meta name="twitter:title" content="Laravel" />

Description

seo()->description('Catchy marketing headline');
<meta name="description" content="Catchy marketing headline" />
<meta property="og:description" content="Catchy marketing headline" />
<meta name="twitter:description" content="Catchy marketing headline" />

CSRF Token

seo()->csrfToken();
<meta name="csrf-token" content="a7588c617ea5d8833374d8eb3752bcc4071" />

Charset & Viewport

seo()->charset();
seo()->viewport();
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

Twitter

seo()->twitter('card', 'summary');
seo()->twitter('creator', '@romanzipp');
<meta name="twitter:card" content="summary" />
<meta name="twitter:creator" content="@romanzipp" />

Open Graph

seo()->og('site_name', 'Laravel');
seo()->og('locale', 'de_DE');
<meta name="og:site_name" content="Laravel" />
<meta name="og:locale" content="de_DE" />

Meta

seo()->meta('copyright', 'Roman Zipp');
<meta name="copyright" content="Roman Zipp" />

For more information see the structs documentation.

Sections

You can add structs to different sections by calling the section('foo') method on the SeoService instance or passing it as the first attribute to the seo('foo') helper method.

Sections allow you to create certain namespaces for Structs which can be used in many different ways: Distinct between "frontend" and "admin" page sections or "head" and "body" view sections.

Using sections

// This struct will be added to the "default" section
seo()->twitter('card', 'summary');

// This struct will be added to the "secondary" section
seo()->section('secondary')->twitter('card', 'image');

// This struct will be also added to the "default" section since the section() method changes are not persistent 
seo()->twitter('card', 'summary');

Rendering sections

This will render all structs added to the "default" section.

{{ seo()->render() }}

This will render all structs added to the "secondary" section.

{{ seo()->section('secondary')->render() }}

Of course, you can also pass the section as parameter to the helper function.

{{ seo('secondary')->render() }}

Laravel-Mix Integration

You can include your mix-manifest.json file generated by Laravel-Mix to automatically add preload/prefetch link elements to your document head.

Basic example

seo()
    ->mix()
    ->load();

mix-manifest.json

{
  "/js/app.js": "/js/app.js?id=123456789",
  "/css/app.css": "/css/app.css?id=123456789"
}

document <head>

<link rel="prefetch" href="/js/app.js?id=123456789" />
<link rel="prefetch" href="/css/app.css?id=123456789" />

Extended usage

Take a look at the SEO Laravel-Mix integration docs for further usage.

use romanzipp\Seo\Conductors\Types\ManifestAsset;

seo()
    ->mix()
    ->map(static function(ManifestAsset $asset): ?ManifestAsset {

        if (strpos($asset->path, 'admin') !== false) {
            return null;
        }

        $asset->url = "http://localhost/{$asset->url}";

        return $asset;
    })
    ->load(public_path('custom-manifest.json'));

Schema.org Integration

This package features a basic integration for Spaties Schema.org package to generate ld+json scripts. Added Schema types render with the packages structs.

use Spatie\SchemaOrg\Schema;

seo()->addSchema(
    Schema::localBusiness()->name('Spatie')
);
use Spatie\SchemaOrg\Schema;

seo()->setSchemes([
    Schema::localBusiness()->name('Spatie'),
    Schema::airline()->name('Spatie'),
]);

Take a look at the Schema.org package Docs.

Upgrading

Cheat Sheet

Code Rendered HTML
Shorthand Setters
seo()->title('Laravel') <title>Laravel</title>
seo()->description('Laravel') <meta name="description" content="Laravel" />
seo()->meta('author', 'Roman Zipp') <meta name="author" content="Roman Zipp" />
seo()->twitter('card', 'summary') <meta name="twitter:card" content="summary" />
seo()->og('site_name', 'Laravel') <meta name="og:site_name" content="Laravel" />
seo()->charset() <meta charset="utf-8" />
seo()->viewport() <meta name="viewport" content="width=device-width, ..." />
seo()->csrfToken() <meta name="csrf-token" content="..." />
Adding Structs
seo()->add(...) <meta name="foo" />
seo()->addMany([...]) <meta name="foo" />
seo()->addIf(true, ...) <meta name="foo" />
Various
seo()->mix()
seo()->hook()
seo()->render()

Testing

./vendor/bin/phpunit
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].