@@ -44,7 +44,7 @@ The simplest use of this bundle would be to just set some configuration to the
44
44
page :
45
45
title : Page's default title
46
46
metas :
47
- names :
47
+ name :
48
48
description : The default description of the page
49
49
keywords : default, sonata, seo
50
50
@@ -55,7 +55,7 @@ The simplest use of this bundle would be to just set some configuration to the
55
55
'page' => array(
56
56
'title' => 'Page's default title',
57
57
'metas' => array(
58
- 'names ' => array(
58
+ 'name ' => array(
59
59
'description' => 'default description',
60
60
'keywords' => 'default, key, other',
61
61
),
@@ -110,12 +110,15 @@ This bundle provides two ways of using this metadata:
110
110
#. Using the extractors, to extract the ``SeoMetadata `` from already existing
111
111
values (e.g. the title of the page).
112
112
113
- You can also use both ways at the same time for the document. In that case,
114
- the persisted ``SeoMetadata `` can be changed by the extractors.
113
+ You can also combine both ways, even on the same document. In that case, the
114
+ persisted ``SeoMetadata `` can be changed by the extractors, to add or tweak
115
+ the current available SEO information. For instance, if you are writing a
116
+ ``BlogPost `` class, you want the SEO keywords to be set to the tags/category
117
+ of the post and any additional tags set by the admin.
115
118
116
119
Persisting the ``SeoMetadata `` with the document makes it easy to edit for the
117
- admin, while using the extractors makes it perfect to use without doing
118
- anything .
120
+ admin, while using the extractors are perfect to easily use values from the
121
+ displayed content .
119
122
120
123
Both ways are documented in detail in seperate sections:
121
124
@@ -130,8 +133,8 @@ URLs. The CMF allows you to have several URLs for the same content if you need
130
133
that. There are two solutions to avoid penalties with search engines:
131
134
132
135
* Create a canonical link that identifies the original URL:
133
- ``<link rel="canonical" href="/route/org/content"> ``;
134
- * Define an "original url" and redirect the other to that one .
136
+ ``<link rel="canonical" href="/route/org/content"> ``
137
+ * Define an "original url" and redirect all duplicate URLs to it .
135
138
136
139
The ``SeoMetadata `` can be configured with the original URL for the current
137
140
page. By default, this bundle will create a canonical link for the page. If
@@ -162,56 +165,25 @@ you want to change that to redirect instead, you can set the
162
165
),
163
166
);
164
167
165
- Defining a Default
166
- ------------------
167
-
168
- You've learned everything about extracting SEO information from objects.
169
- However, in some cases the object doesn't provide any information or there is
170
- no object (e.g. on a login page). For these cases, you have to configure a
171
- default value. These default values can be configured for the SonataSeoBundle:
172
-
173
- .. configuration-block ::
174
-
175
- .. code-block :: yaml
176
-
177
- # app/config/config.yml
178
- sonata_seo :
179
- page :
180
- title : A Default Title
181
- metas :
182
- names :
183
- keywords : default, sonata, seo
184
- description : A default description
185
-
186
- .. code-block :: php
187
-
188
- // app/config/config.php
189
- $container->loadFromExtension(
190
- 'sonata_seo', array(
191
- 'page' => array(
192
- 'title' => 'A Default Title',
193
- 'metas' => array(
194
- 'names' => array(
195
- 'keywords' => 'default, key, other',
196
- 'description' => 'A default description',
197
- ),
198
- ),
199
- ),
200
- ),
201
- );
202
-
203
- The Standard Title and Description
204
- ----------------------------------
168
+ Defining a Title and Description Template
169
+ -----------------------------------------
205
170
206
171
Most of the times, the title of a site has a static and a dynamic part. For
207
- instance, "The title of the Page - Symfony". Here "- Symfony" is static and
172
+ instance, "The title of the Page - Symfony". Here, "- Symfony" is static and
208
173
"The title of the Page" will be replaced by the current title. It is of course
209
- not nice if you need to add this static part to all your titles in documents.
174
+ not nice if you had to add this static part to all your titles in documents.
175
+
176
+ That's why the CmfSeoBundle provides defining a title and description
177
+ template. When using these settings, there are 2 placeholders available:
178
+ ``%content_title% `` and ``%content_description% ``. These will be replaced with
179
+ the title extracted from the content object and the description extracted from
180
+ the content object.
181
+
182
+ .. caution ::
210
183
211
- That's why the CmfSeoBundle provides standard titles and descriptions. When
212
- using these settings, there are 2 placeholders available: ``%content_title% ``
213
- and ``%content_description% ``. This will be replaced with the title extracted
214
- from the content object and the description extracted from the content object.
184
+ The default title and description set by the SonataSeoBundle do override
185
+ this template. You should make sure that the defaults also follow the
186
+ template.
215
187
216
188
For instance, to configure the titles of the symfony.com pages, you would do:
217
189
@@ -243,10 +215,10 @@ For instance, to configure the titles of the symfony.com pages, you would do:
243
215
character, otherwise the container will try to replace it with the value
244
216
of a container parameter.
245
217
246
- This syntax might look familiair if you have used with the Translation
247
- component before. And that's correct, under the hood the Translation component
248
- is used to replace the placeholders with the correct values. This also means
249
- you get Multi Language Support for free!
218
+ This syntax might look familiar if you have used the Translation component
219
+ before. And that's correct, under the hood the Translation component is used
220
+ to replace the placeholders with the correct values. This also means you get
221
+ Multi Language Support for free!
250
222
251
223
For instance, you can do:
252
224
@@ -315,6 +287,11 @@ And then configure the translation messages:
315
287
title : " %content_title% | Default title"
316
288
description : " Default description. %content_description%"
317
289
290
+ .. tip ::
291
+
292
+ You don't have to escape the percent characters here, since the
293
+ Translation loaders know how to deal with them.
294
+
318
295
For changing the default translation domain (messages), you should use the
319
296
``cmf_seo.translation_domain `` setting:
320
297
0 commit comments