Laravel 8 Artesaos SEOTools Tutorial

In this article, we will see how to use SEO tools in laravel 8. we will give you an example of SEO tools in laravel 8. we will use Artesaos SEOTools for website SEO. Search engine optimization is the process of improving the quality and quantity of website traffic to a website or a web page from search engines.

So, let's see the laravel 8 SEO tutorial, SEO tools in laravel 8, laravel 8 SEO package, laravel website SEO, SEO tools for laravel, laravel 8 SEO integration, laravel  8 SEO packages, SEO in laravel 8.

Artesaos SEOTools provides features like the below list

 

Step 1: Install Artesaos SEOTools Package

In this step, we will install the package using the command line. So, run the below command on your terminal.

composer require artesaos/seotools

 

 

Step 2: Update Provider and Aliases

In this step, we will update config/app.php the file. So, add the below code like this.

config/app.php

<?php

return [
    'providers' => [
        Artesaos\SEOTools\Providers\SEOToolsServiceProvider::class,
        // ...
    ],    
];

You can set up aliases in your config/app.php file.

<?php

return [
    'aliases' => [
        'SEOMeta'       => Artesaos\SEOTools\Facades\SEOMeta::class,
        'OpenGraph'     => Artesaos\SEOTools\Facades\OpenGraph::class,
        'Twitter'       => Artesaos\SEOTools\Facades\TwitterCard::class,
        'JsonLd'        => Artesaos\SEOTools\Facades\JsonLd::class,
        'JsonLdMulti'   => Artesaos\SEOTools\Facades\JsonLdMulti::class,
        // or
        'SEO' => Artesaos\SEOTools\Facades\SEOTools::class,
    ],
];

 

Step 3: Use Facades

You may get access to the SEO tool services using the following facades.

use Artesaos\SEOTools\Facades\SEOMeta;
use Artesaos\SEOTools\Facades\OpenGraph;
use Artesaos\SEOTools\Facades\TwitterCard;
use Artesaos\SEOTools\Facades\JsonLd;
use Artesaos\SEOTools\Facades\JsonLdMulti;
use Artesaos\SEOTools\Facades\SEOTools;

 

 

Step 4: Vendor Publish

In your terminal type below command publish Artesaos\SEOTools package.

php artisan vendor:publish

or

php artisan vendor:publish --provider="Artesaos\SEOTools\Providers\SEOToolsServiceProvider"

after publishing this package you can determine config/seotools.php in your project.

 

Step 5:  Usage in Controller

Now, we use SEOTools in the controller.

<?php

namespace App\Http\Controllers;

use Artesaos\SEOTools\Facades\SEOMeta;
use Artesaos\SEOTools\Facades\OpenGraph;
use Artesaos\SEOTools\Facades\TwitterCard;
use Artesaos\SEOTools\Facades\JsonLd;
// OR with multi
use Artesaos\SEOTools\Facades\JsonLdMulti;

// OR use only single facades
use Artesaos\SEOTools\Facades\SEOTools;

class SEOController extends Controller
{
    public function index()
    {
        SEOMeta::setTitle('Techsolutionstuff | Home');
        SEOMeta::setDescription('This is my page description of techsolutionstuff');
        SEOMeta::setCanonical('https://techsolutionstuff.com');

        OpenGraph::setDescription('This is my page description of techsolutionstuff');
        OpenGraph::setTitle('Techsolutionstuff | Home');
        OpenGraph::setUrl('https://techsolutionstuff.com');
        OpenGraph::addProperty('type', 'articles');

        TwitterCard::setTitle('Techsolutionstuff | Homepage');
        TwitterCard::setSite('@techsolutionstuff');

        JsonLd::setTitle('Techsolutionstuff | Homepage');
        JsonLd::setDescription('This is my page description of techsolutionstuff');
        JsonLd::addImage('path/images/logo.png');

        // OR use single only SEOTools

        SEOTools::setTitle('Techsolutionstuff | Home');
        SEOTools::setDescription('This is my page description of techsolutionstuff');
        SEOTools::opengraph()->setUrl('https://techsolutionstuff.com/');
        SEOTools::setCanonical('https://techsolutionstuff.com');
        SEOTools::opengraph()->addProperty('type', 'articles');
        SEOTools::twitter()->setSite('@techsolutionstuff');
        SEOTools::jsonLd()->addImage('path/images/logo.png');

        return view('posts');
    }
}

 

 

Step 6: Use in View file

Also, you can generate SEO in the blade file.

<html>
<head>
    {!! SEOMeta::generate() !!}
    {!! OpenGraph::generate() !!}
    {!! Twitter::generate() !!}
    {!! JsonLd::generate() !!}
    // OR with multi
    {!! JsonLdMulti::generate() !!}

    <!-- OR -->
    {!! SEO::generate() !!}

    <!-- MINIFIED -->
    {!! SEO::generate(true) !!}

</head>
<body>
 <h3>Laravel 8 SEO Tutorial</h3>
</body>
</html>

 


You might also like :

RECOMMENDED POSTS

FEATURE POSTS