Brijpal Sharma
laravel
Publish on:-March 17th, 2019 ,
Category:- Web Development
Brijpal Sharma
laravel
Publish on:-March 17th, 2019 ,
Category:- Web Development
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.
laravel new seotools
After successful install Laravel Application, we move to the next step.
composer require artesaos/seotools
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,
php artisan vendor:publish --provider="Artesaos\SEOTools\Providers\SEOToolsServiceProvider"
Now everything is done now time to test our Laravel application with SEO tools.
Route::get('article','[email protected]')->name('article');
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'));
}
}
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 on //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
Brijpal Sharma
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...
Tuhin Bepari
Publish on:-September 14th, 2019
Thanks for the great article. This tools is for Programmer. So client or Web master does not have control about Meta title and description like WordPress Yoast has. To solve this problem
//github.com/digitaldreams/laravel-seo-tools
This is a great tools. We can say its Laravel's Yoast.
You must be logged in to post a comment.