0

I have configured SeoBundle as stated in docs:

sonata_seo:
    page:
        title: Default title
        metas:
            name:
                description: Defualt description
                keywords: key1, key2

cmf_seo:
    title: seo.title
    description: seo.description
    content_listener:
        enabled: false

And placed in base.html.twig:

<head>
    {# meta #}
    <meta name=viewport content="width=device-width, initial-scale=1">
    <meta name="format-detection" content="telephone=no"/>

    {{ sonata_seo_title() }}

    {{ sonata_seo_metadatas() }}

    ...
</head>

Now when I refresh page I can see that sonata_seo block title and description are set instead of cmf_seo. In docs there is a warning:

The title and description template is only used when the title is not set on the content object or when the content object is not available, otherwise it'll use the default set by the SonataSeoBundle. You should make sure that the defaults also follow the template.

If only docs would clarify what is "content object" would be great... Anyway I tried removing title and description from sonata_seo block:

sonata_seo:
    page: ~

cmf_seo:
    title: seo.title
    description: seo.description
    content_listener:
        enabled: false

Now my title becomes "Sonata Project" which is default SonataSeoBundle title.

How do I display cmf_seo title? {{ cmf_seo_title() }} is not working.

1 Answers1

0

what is the value of seo.title and seo.description is it something you expect to be translated? Can you serve a longer stacktrace for the exception please?

In general CmfSeoBundle expects some placeholders (%%content_description%%, %%content_title%%, doubled to make it translatable at the end) to enrich the title/description with dynamic data. That dynamic data can live as SeoContent on the document (content object) you are persisting or as so called extractors which fetch the data from the document (content object). In the first case you have to implement SeoAwareInterface in second case you can find several extractors in the [doucmentation[(https://symfony.com/doc/current/cmf/bundles/seo/extractors.html).

If you wanna simply set static titles, you should stay with the SonataSeoBundle. We do simply enrich a template defined in cmf_seo.title|description with dynamic data from the current content. We do need sonata_seo.title for pages with no content documents (i.e. static pages).

  • Please give me some feedback if we simply have to improve our docs, or have to fix some code or if you try to tell me a hidden feature request :-) – Maximilian Berghoff Jul 18 '17 at 09:39