DEV Community

David Oti
David Oti

Posted on

How To Improve SEO in Laravel Applications With Laravel Meta Manager

My quest for a good SEO meta tag implementation in Laravel drove me tech mad to write a package that will add standard SEO meta tags to my application with ease.

However, I had to go the extra mile to research important meta tags and the role they play when it comes to SEO and how they can be used to improve SEO, So literally I had to do most of the heavy lifting. Lets quickly take a detour to what meta tags are and how they can improve SEO before we unveil the package.

What Are Meta Tags?

Meta Tags are used by Google and other search engines in some not-so-obvious ways.

“Meta tags are a great way for webmasters to provide search engines with information about their sites. (They) can be used to provide information to all sorts of clients, and each system processes only the meta tags they understand and ignores the rest. (They) are added to the <head> section of your HTML page.”

Why do meta tags matter?

As previously mentioned, meta tags offer more details about your site to search engines and website visitors who encounter your site in the SERP. They can be optimized to highlight the most important elements of your content and make your website stand out in search results.

Search engines increasingly value good user experience, and that includes making sure that your site satisfies a user’s query as best as it possibly can. Meta tags help with this by making sure that the information searchers need to know about your site is displayed upfront in a concise and useful fashion.

What is Laravel Meta Manager?

Laravel Meta Manager is an SEO tool that is used to improve the SEO of a website or specific page by adding recommended meta tags to your application. Laravel meta manager comes with recommended meta tags like;

  • Standard SEO
  • Dublin Core
  • Facebook OpenGraph
  • Twitter Card

Now, let's jump to the interesting part of how we can use this package in our Laravel applications. First, you have to run the following command to include this package via Composer;

ssh composer require davmixcool/laravel-meta-manager

Once the download is complete, the next thing you have to do is include the service provider within config/app.php.

'providers' => [
        Davmixcool\MetaManager\MetaServiceProvider::class,
];
Enter fullscreen mode Exit fullscreen mode

Laravel 5.5+ uses Package Auto-Discovery, so it doesn't require you to manually add the ServiceProvider.

Then run php artisan vendor:publish --provider="Davmixcool\MetaManager\MetaServiceProvider" to get the config of Laravel Meta Manager.

Once that is done you have to set up default application meta in meta.php config. (Optional but recommended). See Configuration Options to know more.

Once the configuration is complete you can then add the below at the meta area of the page you want to include meta tags;

@include('meta::manager')
Enter fullscreen mode Exit fullscreen mode

The above will use the predefined configurations to pre-fill the generated meta tags. However, if you chose to define certain options on the fly then you can use the code below.

@include('meta::manager', [
    'title'         => 'My Example Title',
    'description'   => 'This is my example description',
    'image'         => 'Url to the image',
])
Enter fullscreen mode Exit fullscreen mode

Conclusion

So that’s how I was able to add standard SEO meta tags to my Laravel application. However, It took me some time to come up with this solution and I hope you like it.

Top comments (0)