SEO tool for Laravel Application

Today’s topic is an SEO tool for Laravel applications. we integrate artesaos/seotools package for the Laravel application.

On the internet to get on the first page of Google SEO is the most important factor so to many methods and ways to stay on the first page of Google.

Today we discuss an SEO artesaos/seotools plugin for Laravel by using this plugin we can easily manage all page’s titles, descriptions, keywords, and many more. so let’s start.

Step:1 Create a  new Laravel Application.

laravel new seotools

After successfully installing the Laravel Application, we move to the next step.

Step: 2 Install Package.

composer require artesaos/seotools

Step:3 update configuration of Application.

Now you need to update your application configuration, just update your config/app.php file adding the following code at the end of your providers’ section.

Artesaos\SEOTools\Providers\SEOToolsServiceProvider::class,

In order to use the SEO Meta facade, you need to add it on the config/app.php file, you can do that the following way.

 'SEOMeta'   => Artesaos\SEOTools\Facades\SEOMeta::class,
 'OpenGraph' => Artesaos\SEOTools\Facades\OpenGraph::class,
 'Twitter'   => Artesaos\SEOTools\Facades\TwitterCard::class,
        // or
 'SEO'       => Artesaos\SEOTools\Facades\SEOTools::class,

Step:4 Publish config

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

Now everything is done now time to test our Laravel application with SEO tools.

Step:1 Create a route

Route::get('article','ArticleController@article')->name('article');

Step: 2 Create a controller

php artisan make:controller ArticleController

add some code into ArticleController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use SEOMeta;
use OpenGraph;
use Twitter;
## or
use SEO;
class ArticleController extends Controller
{
    public function article()
    {
    	
        $title = "This is a blog title";
        $description ="This is a discription of my blog post";
        $body        = "This is main body of my blog post";

        SEO::setTitle($title);
        SEO::setDescription('This is my page description');
      
        return view('article',compact('title','description','body'));
    }
}

Step:3 Create a new view article.blade.php

And some HTML code to view title, description, and body which is passed from the controller with SEO meta details. 

<!DOCTYPE html>
<html>
<head>
	{!! SEO::generate() !!}

</head>
<body>
	<h1>{{$title}} </h1> <br>
	<h2>{{$description}} </h2> <br>
	<p>{{$body}} </p>
</body>
</html>

Now we can see the result on the view page and see the SEO meta tag on the view source page.

View-source

To get more detail about this package you can visit //github.com/artesaos/seotools 

So here we completed the tutorial on the SEO tool for Laravel Application.

Read our another article on Laravel Paypal payment gateway integration in Laravel 5.7 step by step

Read also Top 10 Most Common SEO Problems