Skip to main content
Back to packages
859 GitHub stars

ralphjsmit/laravel-seo

View on GitHub

Description

Never worry about SEO in Laravel again!

This package generates valid and useful meta tags straight out-of-the-box, with limited initial configuration, while still providing a simple, but powerful API to work with. It can generate:

  1. Title tag (with sitewide suffix)
  2. Meta tags (author, description, image, robots, etc.)
  3. OpenGraph Tags (Facebook, LinkedIn, etc.)
  4. Twitter Tags
  5. Structured data (Article, Breadcrumbs, FAQPage, or any custom schema)
  6. Favicon
  7. Robots tag
  8. Alternates links tag

If you're familiar with Spatie's media-library package, this package works in almost the same way, but then only for SEO. I'm sure it will be very helpful for you, as it's usually best for a website to have attention for SEO right from the beginning.

Here are a few examples of what you can do:

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

It will render the SEO tags directly on your page:

<!DOCTYPE html>
<html>
<head>
{!! seo()->for($post) !!}
 
{{-- No need to separately render a <title> tag or any other meta tags! --}}
</head>

It even allows you to dynamically retrieve SEO data from your model, without having to save it manually to the SEO model. The below code will require zero additional work from you or from your users:

class Post extends Model
{
use HasSEO;
 
public function getDynamicSEOData(): SEOData
{
$pathToFeaturedImageRelativeToPublicPath = // ..;
 
// Override only the properties you want:
return new SEOData(
title: $this->title,
description: $this->excerpt,
image: $pathToFeaturedImageRelativeToPublicPath,
);
}
}

Related Content on Laravel Daily

Video

Recent Courses on Laravel Daily

Laravel 13 Starter Kit Teams and Customizations

10 lessons
33 min

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read

How to Build Laravel 13 API From Scratch

30 lessons
1 h 23 min

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.