1. Installation

To begin, require the bundle via Composer:

1
composer require sonata-project/seo-bundle

Now, add the new SeoBundle Bundle to bundles.php file:

// config/bundles.php

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

1.1. Configuration

To use the SeoBundle, add the following lines to your application configuration file.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# config/packages/sonata_seo.yaml

sonata_seo:
    encoding:         UTF-8
    page:
        title:           'Project name'
        # title_prefix:  'Prefix |'
        # title_suffix:  '| Suffix'
        default:          sonata.seo.page.default
        metas:
            name:
                keywords:             foo bar
                description:          The description
                robots:               index, follow

            property:
                # Facebook application settings
                #'fb:app_id':          XXXXXX
                #'fb:admins':          admin1, admin2

                # Open Graph information
                # see http://developers.facebook.com/docs/opengraphprotocol/#types or http://ogp.me/
                'og:site_name':       Sonata Project Sandbox
                'og:description':     A demo of the some rich bundles for your Symfony2 projects

            http-equiv:
                'Content-Type':         text/html; charset=utf-8
                #'X-Ua-Compatible':      IE=EmulateIE7

            charset:
                UTF-8:    ''

        head:
            'xmlns':              http://www.w3.org/1999/xhtml
            'xmlns:og':           http://opengraphprotocol.org/schema/
            #'xmlns:fb':           "http://www.facebook.com/2008/fbml"