Blog Detail

17

Feb
Improve your Website's Seo Ranking with Laravel-Seo Package cover image

arrow_back Improve your Website's Seo Ranking with Laravel-Seo Package

Roman Zipp has introduced an amazing package for Seo called Laravel-SEO. This package can be utilized for improving your application SEO with maximum customization and flexibility.

Installation

You can install this package via composer by running this command.

composer require romanzipp/laravel-seo

Configuration

Copy configuration to config folder:

$ php artisan vendor:publish --provider="romanzipp\Seo\Providers\SeoServiceProvider"

Usage

Instantiation

You can access the SEO service in many different ways. Just use what you prefer! We will use the seo() function in this documentation.

use romanzipp\Seo\Facades\Seo;
use romanzipp\Seo\Services\SeoService;

$seo = seo();

$seo = app(SeoService::class);

$seo = Seo::make();

Render

Place this code snippet in your blade view.

{{ seo()->render() }}

How to register tags

Going forward we will refer to head/meta elements as Structs.

This package offers many ways of adding new elements Structs to your head.

Shorthand setters

Shorthand setters are predefined shortcuts to add commonly used Structs without the hassle of importing struct classes or chaining many methods.

When using shorthand methods, you will skip the seo()->add() method. You can configure which Structs should be added on shorthand calls in the seo.php config file under the shorthand key.

Title

seo()->title('Laravel');

renders to

<title>Laravel</title>
<meta property="og:title" content="Laravel" />
<meta name="twitter:title" content="Laravel" />

Meta

seo()->meta('copyright', 'Roman Zipp');

renders to

<meta name="copyright" content="Roman Zipp" />

Take a look at the shorthand setter docs for all available methods.

This package has a lot of advanced features like adding structs, array format, using & rendering sections, etc. If you want to explore all the features, you can visit its documentation here and source code on Github.

Published at : 17-02-2022

Author : Rizwan Aslam
AUTHOR
Rizwan Aslam

I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.

Launch your project

Launch project