An open API service indexing awesome lists of open source software.

https://github.com/abdellahrk/seobundle

A complete SEO solution for Symfony projects. This bundle handles meta tags, Open Graph, Twitter Cards, canonical URLs, sitemaps, and more—helping your app stay search-engine friendly and socially shareable out of the box.
https://github.com/abdellahrk/seobundle

canonical-urls meta-tags meta-tags-management open-graph robots-txt search-engine-optimization seo seo-bundle sitemaps social-sharing symfony-seo twitter-cards webmaster-tools

Last synced: 9 months ago
JSON representation

A complete SEO solution for Symfony projects. This bundle handles meta tags, Open Graph, Twitter Cards, canonical URLs, sitemaps, and more—helping your app stay search-engine friendly and socially shareable out of the box.

Awesome Lists containing this project

README

          

This Bundle supports
====================
- [x] [Meta Tags](docs/meta_tags.md)
- [x] [OpenGraph (Twitter Cards, Facebook, LinkedIn, Instagram, Discord and more)](docs/open_graph.md)
- [x] [Structured Data (Schema)](docs/schema.md)
- [x] [Sitemap Generation](docs/sitemap.md)
- [x] [Google Tag](docs/google_tag.md)
- [x] [Meta Pixel](docs/meta_pixel.md)
- [ ] SEO Profiling [Dev mode]
- [ ] Breadcrum Generation

Installation
============

Make sure Composer is installed globally, as explained in the
[installation chapter](https://getcomposer.org/doc/00-intro.md)
of the Composer documentation.

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

```console
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:

```php
// config/bundles.php

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

#### 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

```php
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')
;
}
```

2. Directly in twig
```php
{{ 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)
```php

{{ meta_tags() }}

```

This will render in the head the following

```html

My Title


```

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
```php

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
```html

```
You can also leave out setting the properties in the controller and set directly in Twi
```php
{{ meta_tags(title: 'My website', siteName: 'My Blog') }}
```

full document at [Open Graph Docs](docs/open_graph.md)

Schema Org [Rich Result]
========================

### Usage

```php
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('abdellah@hey.cm')
->children([
$schema->person()->name('Rami')->email('ramadanabdel24@gmail.com')->givenName('Ramadan'),
$schema->person()->name('Rami 3')->email('test@gmail.com')
]);
$schema->render($person);
}
```
enable the schema in the config:

```yaml
seo:
schema:
enabled: true
```

This is an example using the `Person` object which will render

```html

{
"@context": "https://schema.org",
"@type": "Person",
"name": "Abdel Ramadan",
"email": "abdellah@hey.cm",
"children": [
{
"@type": "Person",
"name": "Rami",
"email": "ramadanabdel24@gmail.com",
"givenName": "Ramadan"
},
{
"@type": "Person",
"name": "Rami 3",
"email": "test@gmail.com"
}
]
}

```
Full Schema docs at [Schema Org Docs](docs/schema.md)

Sitemap Generation
==================

This package automates the generation of sitemaps.

### Usage

```php
#[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


https://mysite.com/blog


https://mysite.com/

```

Full Sitemap docs [Sitemap Docs](docs/sitemap.md)

Full documentation at [Documentation](docs/index.md)