1. Go to this page and download the library: Download secretcv/laravel-meta library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Meta;
abstract class Controller extends BaseController
{
use DispatchesCommands, ValidatesRequests;
public function __construct()
{
# Default title
Meta::title('This is default page title to complete section title');
# Default robots
Meta::set('robots', 'index,follow');
}
}
namespace App\Http\Controllers;
use Meta;
class HomeController extends Controller
{
public function index()
{
# Section description
Meta::set('title', 'You are at home');
Meta::set('description', 'This is my home. Enjoy!');
Meta::set('image', asset('images/home-logo.png'));
return view('index');
}
public function detail()
{
# Section description
Meta::set('title', 'This is a detail page');
Meta::set('description', 'All about this detail page');
Meta::set('image', asset('images/detail-logo.png'));
return view('detail');
}
public function private()
{
# Section description
Meta::set('title', 'Private Area');
Meta::set('description', 'You shall not pass!');
Meta::set('image', asset('images/locked-logo.png'));
# Custom robots for this section
Meta::set('robots', 'noindex,nofollow');
return view('private');
}
}
return [
/*
|--------------------------------------------------------------------------
| Limit title meta tag length
|--------------------------------------------------------------------------
|
| To best SEO implementation, limit tags.
|
*/
'title_limit' => 70,
/*
|--------------------------------------------------------------------------
| Limit description meta tag length
|--------------------------------------------------------------------------
|
| To best SEO implementation, limit tags.
|
*/
'description_limit' => 200,
/*
|--------------------------------------------------------------------------
| Limit image meta tag quantity
|--------------------------------------------------------------------------
|
| To best SEO implementation, limit tags.
|
*/
'image_limit' => 5,
/*
|--------------------------------------------------------------------------
| Available Tag formats
|--------------------------------------------------------------------------
|
| A list of tags formats to print with each definition
|
*/
'tags' => ['Tag', 'MetaName', 'MetaProperty', 'TwitterCard'],
];