SEO tool for Laravel Application



Today topic is SEO tool for Laravel Application. we integrate artesaos/seotools package for Laravel application.

SEO tool for Laravel Application

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

Today we Discus an SEO artesaos/seotools plugin for Laravel by using this plugin we can easily manage all pages title, description, keyword and many more. so let's start.

Step:1 Create a  new Laravel Application.

laravel new seotools

After successful install 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.

SEO tool for Laravel Application

View-source

SEO tool for Laravel Application

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

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

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


About Author
  • user profile
    Brijpal Sharma

    brijpalsharma99@gmail.com, January 29th, 2018

    Hello, My Name is Brijpal Sharma. I am a Web Developer, Professional Blogger and Digital Marketer from India. I am the founder of Codermen. I started this blog to help web developers & bloggers by providing easy and best tutorials, articles and offers for web developers and bloggers...


0 Comment


You must be logged in to post a comment.