Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Seo Bundle Laravel Package

abdellahramadan/seo-bundle

Symfony SEO bundle providing meta tags, Open Graph/Twitter cards, Schema.org structured data, sitemap generation, breadcrumbs, Google Tag and Meta Pixel integration, plus dev-mode SEO profiling. Configure via DI or Twig helpers for easy template rendering.

View on GitHub
Deep Wiki
Context7

This Bundle supports

Installation

Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.

Open a command console, enter your project directory and execute:

composer require rami/seo-bundle

This will enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:

// config/bundles.php

return [
    // ...
    Abdellahramadan\SeoBundle\SeoBundle::class => ['all' => true],
];

Profiler

For full documentation, click on the desired topic above to be taken to its documentation page

Meta Tags

Example

Define Meta Tags in Two ways:

  1. Type hint the MetaTagsInterface into a controller
use Abdellahramadan\SeoBundle\Metas\MetaTagsManagerInterface;


public function myController(MetaTagsManagerInterface $metaTags): Response 
{
    $metaTags->setTitle('My Title')
        ->setDescription('This is the description of the page')
        ->setKeywords(['keywords', 'seo', 'meta'])
        ->setCanonical('https://canonical.com')
    ;
}
  1. Directly in twig
{{ meta_tags(title: 'My Title', description: 'This is the description of the page' ...)}

Make sure you add this {{ meta_tags }} to the head your Twig file (preferably the base template)

<head>
    {{ meta_tags() }}
</head>

This will render in the head the following

<head>
    <title>My Title</title>
    <meta name="description" content="This is the description of the page'">
    <meta name="keywords" content="keywords, seo, meta">
    <link rel="canonical" href="https://canonical.com">
</head>

Open Graph

Example

Add to template file

Add {{ open_graph() }} to the base template or any page where the meta information will be injected

Add meta inforation

In your controller, type-hint OpenGraphInterface

Example


use Abdellahramadan\OpenGraphBundle\OpenGraph\OpenGraphManagerInterface;

class HomeController extends AbstractController
{
    public function index(OpenGraphManagerInterface $openGraph): Response
    {
        $openGraph
            ->setTitle('My website')
            ->setDescription('Some descriptions ...')
            ->setSiteName('My Blog')
        ;
            ...
        return $this-render('index.html.twig');
    }
}

This will render

<meta property="og:title" content="My website">
<meta property="og:description" content="Some descriptions ...">
<meta property="og:site_name" content="My Blog">

You can also leave out setting the properties in the controller and set directly in Twi

{{ meta_tags(title: 'My website', siteName: 'My Blog') }}

full document at Open Graph Docs

Schema Org [Rich Result]

Usage

use Rami\SeoBundle\Schema\SchemaInterface;
use Symfony\Component\HttpFoundation\Response;

...
    #[Route('/', name: 'app_home')]
    public function index(SchemaInterface $schema): Response
    {
        $person = $schema
            ->person()
            ->name('Abdel Ramadan')
            ->email('[email protected]')
            ->children([
                $schema->person()->name('Rami')->email('[email protected]')->givenName('Ramadan'), 
                $schema->person()->name('Rami 3')->email('[email protected]')
            ]);
        $schema->render($person);
    }

enable the schema in the config:

seo:
  schema:
    enabled: true

This is an example using the Person object which will render

<script type="application/ld+json">
{
    "@context": "https://schema.org",
    "@type": "Person",
    "name": "Abdel Ramadan",
    "email": "[email protected]",
    "children": [
        {
            "@type": "Person",
            "name": "Rami",
            "email": "[email protected]",
            "givenName": "Ramadan"
        },
        {
            "@type": "Person",
            "name": "Rami 3",
            "email": "[email protected]"
        }
    ]
}
</script>

Full Schema docs at Schema Org Docs

Sitemap Generation

This package automates the generation of sitemaps.

Usage

    #[Sitemap()]
    #[Route('/', name: 'app_home')]
    public function index() {
        ...
    }

    #[Sitemap()]
    #[Route('/blog', name: 'blog')]
    public function blogIndex() {
        ...
    }

This will add the the url entries into sitemaps/default.xml

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://mysite.com/blog</loc>
  </url>
  <url>
    <loc>https://mysite.com/</loc>
  </url>
</urlset>

Full Sitemap docs Sitemap Docs

Full documentation at Documentation

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel