Laravel SEO, some packages to generate meta tags

- Andrés Cruz

En español
Laravel SEO, some packages to generate meta tags

This material is part of my complete course and book; You can purchase them from the books and/or courses section, Curso y libro Laravel 11 con Tailwind Vue 3, introducción a Jetstream Livewire e Inerta desde cero - 2024.

There are multiple packages to generate SEO tags for Laravel, this is great since there are certain parts of the application that need to return some met tags exactly where we need them, without worrying about whether the names of these tags are correct or not, it already generates them the package by us:

SEOTools 

This is a package that allows you to easily generate meta tags by using methods:

 

https://github.com/artesaos/seotools

$ composer require artesaos/seotools

With this, we can now use methods to generate the labels such as:

SEOTools::setTitle("Latest posts");
SEOTools::opengraph()->addProperty('type', 'articles');
SEOTools::twitter()->setSite('@LibreDesarrollo');
SEOTools::jsonLd()->addImage(URL::to('/public/images/logo/logo.png'));
SEOTools::setDescription("Here you will find the latest posts that I have uploaded to my blog.");

From view:

{!! SEO::generate() !!}
<!-- MINIFIED -->
{!! SEO::generate(true) !!}

And we have:

<title>Latest posts</title>
<meta name="description" content="Here you will find the latest posts that I have uploaded to my blog.">
<meta property="og:title" content="Latest posts"><meta property="og:type" content="articles">
<meta property="og:description" content="Here you will find the latest posts that I have uploaded to my blog.">
<meta name="twitter:title" content="Latest posts"><meta name="twitter:site" content="@LibreDesarrollo">
<meta name="twitter:description" content="Here you will find the latest posts that I have uploaded to my blog.">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Últimas publicaciones","description":"Here you will find the latest posts that I have uploaded to my blog."}</script>

To customize the package as default values or title suffixes, you must publish the configuration file:

$ php artisan vendor:publish --provider="Artesaos\SEOTools\Providers\SEOToolsServiceProvider"

Laravel SEO

This package generates meta tags used for SEO:

  • Title tag (with site-wide suffix)
  • Meta tags (author, description, image, robots, etc.)
  • OpenGraph tags (Facebook, LinkedIn, etc.)
  • Twitter tags
  • Structured data (article and breadcrumb)
  • Favicon
  • robots tag

https://github.com/ralphjsmit/laravel-seo

$ composer require ralphjsmit/laravel-seo

With this, we can now use methods to generate the labels such as:

$post = Post::find(1);

$post->seo->update([
 'title' => 'My great post',
 'description' => 'This great post will enhance your live.',
]);

From view:

{!! seo()->for($post) !!}

There are several other settings that you can find in the official documentation.

Andrés Cruz

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.