PHPackages                             umanit/seo-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. umanit/seo-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

umanit/seo-bundle
=================

Provides SEO features on Doctrine entities.

3.0.6(9mo ago)712.1k↓50%3[3 issues](https://github.com/umanit/seo-bundle/issues)MITPHPPHP ^8.1CI failing

Since Feb 4Pushed 9mo ago3 watchersCompare

[ Source](https://github.com/umanit/seo-bundle)[ Packagist](https://packagist.org/packages/umanit/seo-bundle)[ Docs](https://github.com/umanit/seo-bundle)[ RSS](/packages/umanit-seo-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (39)Used By (0)

Umanit Seo Bundle
=================

[](#umanit-seo-bundle)

This bundle adds SEO capabilities for any model entities.

Features
--------

[](#features)

- 301 Redirects when accessing an old URL
- SEO Metadata (title and description)
- Canonical URL
- Schema.org
- Breadcrumb
- Sitemap

Installation
------------

[](#installation)

`$ composer require umanit/seo-bundle`

Configuration
-------------

[](#configuration)

The template needs to be declared in your Twig configuration, **before** other templates. You must choose one between:

```
twig:
    # ...
    form_themes:
        - '@UmanitSeo/sylius/form/fields.html.twig'
        # OR
        - '@UmanitSeo/sonata/form/fields.html.twig'
        - ...
```

You can configure your bundle further by creating a `umanit_seo.yaml` configuration file. Here is the default configuration provided by the bundle:

```
# Default configuration for extension with alias: "umanit_seo"
umanit_seo:

    # Historize URLs of entities which implements HistorizableUrlModelInterface
    url_historization:
        enabled: true

        # Redirect code used by UrlRedirectorSubscriber
        redirect_code: 301

        # Cache service used to store entities dependencies. **MUST** implements \Symfony\Contracts\Cache\CacheInterface
        cache_service: cache.app

    # Defines the default templates used to render breadcrumbs
    templates:
        breadcrumb_json_ld: '@UmanitSeo/breadcrumb/breadcrumb.json-ld.html.twig'
        breadcrumb_microdata: '@UmanitSeo/breadcrumb/breadcrumb.microdata.html.twig'
        breadcrumb_rdfa: '@UmanitSeo/breadcrumb/breadcrumb.rdfa.html.twig'
    metadata:
        form_type:

            # Automaticaly add a SeoMetadataType on FormType which handled an entity which implements HasSeoMetadataInterface
            add_seo_metadata_type: true

            # FQCN of the FormType used to renders SEO Metadata fields
            class_fqcn: Umanit\SeoBundle\Form\Type\SeoMetadataType

            # Injects Google Code Prettify when rendering breadcrumb and schema.org in FormType.
            inject_code_prettify: true
        default_title: 'Umanit Seo - Customize this default title to your needs.'
        title_prefix: ''
        title_suffix: ''
        default_description: 'Umanit Seo - Customize this default description to your needs.'
```

Usage
-----

[](#usage)

1. [Basic Usage](#basic-usage)
2. [Seo Metadata](#seo-metadata)
3. [Schema.org](#schemaorg-implementation)
4. [Breadcrumb](#breadcrumb)
5. [Enabling 301 redirects](#enabling-301-redirects)
6. [Twig functions reference](#twig-functions-reference)
7. [Protips](#protips)

### Basic usage

[](#basic-usage)

In order to function properly, SeoBundle must be able to generate a URL for a given entity. To do so, the `umanit_seo.routable` service uses handlers to process the entity.

A handler is a service which implements `Umanit\SeoBundle\Handler\Routable\RoutableHandlerInterface`. A `supports`method indicated if the service can handle the given entity and a `process` method do the job by returning a `Umanit\SeoBundle\Model\Route` object.

The `Umanit\SeoBundle\Model\Route` object has a `name` attribute, which is the name of the route used to access the entity and a `parameters` attribute used to build the route.

**You must implement the interface `Umanit\SeoBundle\Model\RoutableModelInterface` on your entity and create a handler to process it.**

```
