1
1
SeoContentBundle
2
2
================
3
3
4
- This bundle helps you optimize your websites
5
- for search engines by collecting SEO data in
6
- a central location and making it available in
7
- twig. It is built on top of the SonataSeoBundle.
4
+ This bundle helps you optimize your websites for search engines by
5
+ collecting SEO data in a central location and making it available in twig.
6
+ It is built on top of the SonataSeoBundle.
8
7
9
8
Preface
10
9
-------
11
10
12
- Search engines punish you when you provide
13
- the same content under several URLs.
14
- The CMF allows you to have several URLs
15
- for the same content if you need that.
16
- There are two solutions to avoid penalties
17
- with search engines:
11
+ Search engines punish you when you provide the same content under several
12
+ URLs. The CMF allows you to have several URLs for the same content if you
13
+ need that. There are two solutions to avoid penalties with search engines:
18
14
19
- - Create a canonical link that identifies the
20
- original URL: ``<link rel="canonical" href="/route/org/content"> ``
15
+ * Create a canonical link that identifies the original URL:
16
+ ``<link rel="canonical" href="/route/org/content"> ``;
17
+ * Redirect to THE original url.
21
18
22
- - Redirect to THE original url.
19
+ Both take care on search engines, which does not like it to have same content
20
+ under different routes.
23
21
24
- Both take care on search engines, which does not like
25
- it to have same content under different routes.
26
-
27
- The SeoBundle uses sonatas SeoBundle and its TwigHelper
28
- to render the the `SeoMetadata ` into your Pag. So you
29
- should have a look at the documentation
30
- at `sonata seo documentation_ `
22
+ The SeoBundle uses sonatas SeoBundle and its TwigHelper to render the the
23
+ `SeoMetadata ` into your Pag. So you should have a look at the documentation at
24
+ `sonata seo documentation_ `
31
25
32
26
Installation
33
27
------------
34
28
35
- You can install the bundle in 2 different ways:
36
-
37
- * Use the official Git repository `with github `_
38
- * Install it `with composer `_ (``symfony-Symfony CMF/seo-content-bundle `` on `Packagist `_).
39
-
40
- Both bundles need to be registered in the ``appKernel ``
29
+ You can install this bundle `with composer `_ using the ``symfony-Symfony
30
+ CMF/seo-content-bundle `` package on `Packagist `_.
41
31
42
- .. code-block :: php
32
+ Both the CmfSeoBundle and SonataSeoBundle need to be registered in the
33
+ ``AppKernel ``::
43
34
44
35
// app/appKernel.php
36
+
37
+ // ...
45
38
public function registerBundles()
46
39
{
47
40
$bundles = array(
48
- //register both SeoBundles
41
+ // ...
49
42
new Sonata\SeoBundle\SonataSeoBundle(),
50
43
new Symfony\Cmf\Bundle\SeoBundle\CmfSeoBundle(),
51
44
);
52
45
46
+ // ...
47
+
53
48
return $bundles;
54
49
}
55
50
56
- A very basic use case
57
- _____________________
51
+ A Very Basic Use Case
52
+ ~~~~~~~~~~~~~~~~~~~~~
58
53
59
- The simplest use case would be to just set some configuration
60
- to the sonata_seo configuration section and set the TwigHelper
61
- into your template .
54
+ The simplest use case would be to just set some configuration to the
55
+ `` sonata_seo `` configuration section and use the twig helper in your
56
+ templates .
62
57
63
58
.. configuration-block ::
64
59
@@ -88,14 +83,17 @@ into your template.
88
83
),
89
84
));
90
85
91
- To get a deeper look into the sonata seo-bundle configuration you
92
- should visit its documentation at `sonata seo documentation_ `
93
- The only thing to do now is to insert the TwigHelper into your
94
- template:
86
+ .. seealso ::
95
87
96
- .. code-block :: html
88
+ To get a deeper look into the SonataSeoBundle configuration, you should visit
89
+ the `Sonata documentation `_.
90
+
91
+ The only thing to do now is to use the twig helper in your templates:
92
+
93
+ .. code-block :: html+jinja
97
94
98
95
<!-- app/Resources/views/base.html.twig -->
96
+ <!DOCTYPE html>
99
97
<html>
100
98
<head>
101
99
{{ sonata_seo_title() }}
@@ -107,11 +105,11 @@ template:
107
105
</body>
108
106
</html>
109
107
110
- This will render a Page with the tilte defined above. The
111
- information definded for description and keywords will go
112
- into the meta tags .
108
+ This will render a page with the default title ("Page's default title") as
109
+ title element. The information definded for description and keywords will go
110
+ into the correct metatags .
113
111
114
- Using SeoMetadata - Admin extension and a form type
112
+ Using SeoMetadata - Admin Extension and a form type
115
113
---------------------------------------------------
116
114
117
115
The basic example would work perfect without the Symfony CMF
@@ -123,35 +121,35 @@ called `SeoMetada`:
123
121
124
122
.. code-block :: php
125
123
126
- /**
124
+ /**
127
125
* This string contains the information where we will find the
128
126
* original content. Depending on the setting for the
129
127
* cmf_seo.content.pattern, we will do an redirect to this url or
130
128
* create a canonical link with this value as the href attribute.
131
129
*
132
130
* @var string
133
- */
131
+ *
134
132
private $originalUrl;
135
133
136
134
/**
137
135
* If this string is set, it will be inserted as a meta
138
136
* tag for the page description.
139
137
*
140
138
* @var string
141
- */
139
+ *
142
140
private $metaDescription;
143
141
144
142
/**
145
143
* This comma separated list will contain the Keywords for
146
144
* the page's meta information.
147
145
*
148
146
* @var string
149
- */
147
+ *
150
148
private $metaKeywords;
151
149
152
- A object should implement
153
- the ` SeoAwareInterface `, which simply forced to implement
154
- setter/getter for the seo metadata. A simple example would be:
150
+ A object should implement the `` SeoAwareInterface ``, which simply forces to
151
+ implement the setter and getter for the seo metadata. A simple example would
152
+ be:
155
153
156
154
.. code-block :: php
157
155
@@ -193,14 +191,12 @@ setter/getter for the seo metadata. A simple example would be:
193
191
$manager->persist($route);
194
192
$manager->flush();
195
193
196
- Visiting the site with the url ``/seo-content `` (same template
197
- shown above) will show a Page with "Documents own tile" as
198
- title, "This ist the text for the description meta tag" in
199
- the description, "Seo, Content" in the keywords and a canonical
200
- link with ``href="/original/url/of/content" ``. But what about
201
- some default string to just concatenate defaults and documents
202
- own values? Just add some more configs to the cmf_seo configuration
203
- section.
194
+ Visiting the site with the url ``/seo-content `` (same template shown above)
195
+ will show a Page with "Documents own tile" as title, "This ist the text for
196
+ the description meta tag" in the description, "Seo, Content" in the keywords
197
+ and a canonical link with ``href="/original/url/of/content" ``. But what about
198
+ some default string to just concatenate defaults and documents own values?
199
+ Just add some more configs to the cmf_seo configuration section.
204
200
205
201
.. configuration-block ::
206
202
@@ -246,10 +242,9 @@ section.
246
242
),
247
243
);
248
244
249
- As you will notice, you got the opportunity to set Symfony
250
- translation key for your default values for title and
251
- description. So you will got Multi-Language-Support
252
- out of the box. Just define your values for default
245
+ As you will notice, you got the opportunity to set Symfony translation key for
246
+ your default values for title and description. So you will got
247
+ Multi-Language-Support out of the box. Just define your values for default
253
248
title/description as translations:
254
249
255
250
.. code-block :: xml
@@ -271,18 +266,17 @@ title/description as translations:
271
266
</file >
272
267
</xliff >
273
268
274
- If you want to concatenate your documents values with the
275
- default ones you need them as parameters in you translation
276
- target.
269
+ If you want to concatenate your documents values with the default ones you
270
+ need them as parameters in you translation target.
277
271
278
272
.. tip ::
279
273
280
- If you does not what to open a translation file for two entry,
281
- just set ``Default title | %%content_title%%``or ``Default
282
- description. %%content_description%% ``.
274
+ If you does not what to open a translation file for two entry, just set
275
+ ``Default title | %%content_title%%``or ``Default description.
276
+ %%content_description%% ``.
283
277
284
- For changing the default translation domain (messages), the SeoBundle
285
- provides a configuration value:
278
+ For changing the default translation domain (messages), the SeoBundle provides
279
+ a configuration value:
286
280
287
281
.. configuration-block ::
288
282
@@ -311,8 +305,7 @@ provides a configuration value:
311
305
),
312
306
);
313
307
314
- For redirects instead of canonical links (default) set the following
315
- option:
308
+ For redirects instead of canonical links (default) set the following option:
316
309
317
310
.. configuration-block ::
318
311
@@ -341,11 +334,11 @@ option:
341
334
),
342
335
);
343
336
344
- This value will cause a redirect to the url persisted in the
345
- `` originalUrl `` property of the ``SeoMetadata ``.
337
+ This value will cause a redirect to the url persisted in the `` originalUrl ``
338
+ property of the ``SeoMetadata ``.
346
339
347
- The SeoMetadata contains a form type for your Symfony Form.
348
- Just create you form with the following key:
340
+ The SeoMetadata contains a form type for your Symfony Form. Just create you
341
+ form with the following key:
349
342
350
343
.. code-block :: php
351
344
@@ -355,40 +348,39 @@ Just create you form with the following key:
355
348
...
356
349
;
357
350
358
- For SonataAdminBundle user the SeoBundle provides an admin extension
359
- to add that form to your form configuration.
351
+ For SonataAdminBundle user the SeoBundle provides an admin extension to add
352
+ that form to your form configuration.
360
353
361
- Using extractors for getting your documents seo metadata
354
+ Using Extractors for Getting Your Documents Seo Metadata
362
355
--------------------------------------------------------
363
356
364
- Instead of setting every value to the ``SeoMetadata `` manually
365
- a strategy solution to extract the values from your content document
366
- can be chosen. To do so you got the possibility to add strategies to
367
- your document for each value one by one. Depending on the
368
- strategy a method on the document is called to extract the
369
- value. It is up to the developer how to implement that extraction methods.
370
-
371
- +--------------------------+------------------------+-----------------------------------------------+
372
- | StrategyInterface | method call | Description |
373
- +==========================+========================+===============================================+
374
- | SeoDescriptionExtractor | getSeoDescription() | the documents part for the page description |
375
- +--------------------------+------------------------+-----------------------------------------------+
376
- | SeoOriginalRouteExtractor | getSeoOriginalRoute() |return a ``Route`` object to redirect to |
377
- | | |or create a canonical link from |
378
- +--------------------------+------------------------+-----------------------------------------------+
379
- | SeoOriginalUrlExtractor | getSeoOriginalUrl() |return a absolute url object to redirect to |
380
- | | |or create a canonical link from |
381
- +--------------------------+------------------------+-----------------------------------------------+
382
- | SeoTitleExtractor | getSeoTitle() |return a string for setting the page title |
383
- +--------------------------+------------------------+-----------------------------------------------+
384
- | TitleReadExtractor | - |if implemented the ``getTitle()`` the |
385
- | | |extractor will use this |
386
- +--------------------------+------------------------+-----------------------------------------------+
387
-
388
- For customizing the extraction process you have got the opportunity
389
- to create your own extractor. Just by implementing the
390
- ``SeoExtractorInterface `` and tagging the service as
391
- ``cmf_seo.extractor ``
357
+ Instead of setting every value to the ``SeoMetadata `` manually a strategy
358
+ solution to extract the values from your content document can be chosen. To do
359
+ so you got the possibility to add strategies to your document for each value
360
+ one by one. Depending on the strategy a method on the document is called to
361
+ extract the value. It is up to the developer how to implement that extraction
362
+ methods.
363
+
364
+ +-----------------------------------+---------------------------+---------------------------------------------+
365
+ | StrategyInterface | method call | Description |
366
+ +===================================+===========================+=============================================+
367
+ | ``SeoDescriptionReadInterface `` | ``getSeoDescription() `` | the documents part for the page description |
368
+ +-----------------------------------+---------------------------+---------------------------------------------+
369
+ | ``SeoOriginalRouteReadInterface `` | ``getSeoOriginalRoute() `` | return a ``Route `` object to redirect to |
370
+ | | | or create a canonical link from |
371
+ +-----------------------------------+---------------------------+---------------------------------------------+
372
+ | ``SeoOriginalUrlReadInterface `` | ``getSeoOriginalUrl() `` | return a absolute url object to redirect to |
373
+ | | | or create a canonical link from |
374
+ +-----------------------------------+---------------------------+---------------------------------------------+
375
+ | ``SeoTitleReadInterface `` | ``getSeoTitle() `` | return a string for setting the page title |
376
+ +-----------------------------------+---------------------------+---------------------------------------------+
377
+ | - | ``getTitle() `` | if implemented the ``getTitle() `` the |
378
+ | | | extractor will use this |
379
+ +-----------------------------------+---------------------------+---------------------------------------------+
380
+
381
+ For customizing the extraction process, you have got the opportunity to create
382
+ your own extractor. Just by implementing the ``SeoExtractorInterface `` and
383
+ tagging the service as ``cmf_seo.extractor ``
392
384
393
385
.. code-block :: xml
394
386
@@ -412,5 +404,4 @@ to create your own extractor. Just by implementing the
412
404
413
405
.. _`with composer` : http://getcomposer.org
414
406
.. _`packagist` : https://packagist.org/packages/symfony-cmf/menu-bundle
415
- .. _`with github` : git clone https://github.com/symfony-cmf/SeoContentBundle
416
- .. _`sonata seo documentation` : http://sonata-project.org/bundles/seo/master/doc/index.html
407
+ .. _`Sonata documentation` : http://sonata-project.org/bundles/seo/master/doc/index.html
0 commit comments