我已经配置了SeoBundle,如文档中所述
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放置在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>现在,当我刷新页面时,我可以看到设置了sonata_seo块标题和描述,而不是cmf_seo。在文档中有一个警告:
只有在没有在内容对象上设置标题或当内容对象不可用时才使用标题和描述模板,否则它将使用SonataSeoBundle设置的默认设置。您应该确保默认设置也遵循模板。
如果docs能澄清什么是“内容对象”就好了.无论如何,我尝试从sonata_seo块中删除标题和描述:
sonata_seo:
page: ~
cmf_seo:
title: seo.title
description: seo.description
content_listener:
enabled: false现在我的标题变成了“奏鸣曲项目”,这是默认的SonataSeoBundle标题。
如何显示cmf_seo标题?{{ cmf_seo_title() }}不工作。
发布于 2017-07-17 10:21:36
seo.title和seo.description的价值是什么?它是你希望翻译的东西吗?您能为异常提供更长的堆栈跟踪吗?
通常,CmfSeoBundle需要一些占位符(%%content_description%%,%%content_title%%,加倍以便在末尾可翻译)来用动态数据丰富标题/描述。动态数据可以在持久化的文档(content )上以SeoContent的形式存在,也可以像所谓的提取器那样从文档(content )中获取数据。在第一种情况下,您必须在第二种情况下实现SeoAwareInterface,您可以在[doucmentation[((https://symfony.com/doc/current/cmf/bundles/seo/extractors.html))]中找到几个提取器。
如果您想简单地设置静态标题,则应该使用SonataSeoBundle。我们只是简单地用来自当前内容的动态数据充实了cmf_seo.title|description中定义的模板。对于没有内容文档的页面(即静态页面),我们确实需要sonata_seo.title。
https://stackoverflow.com/questions/45116949
复制相似问题