我正在使用Hippo CMS

在不成功使用HST SEO support plugin之后,我意识到HstResponse::addHeadElement对我的HTML页面没有任何影响。

例如,在组件代码中添加以下行时:

Element title = response.createElement("title");
title.setTextContent("Foo");
response.addHeadElement(title, "hst.seo.document.title");


我希望相应的<title>Foo</title>标记包含在响应中,但事实并非如此。

我错过了什么?

最佳答案

问题是布局文件中没有适当的hst:headContributions节点。

我有两个,分别用于两个不同的类别:

<hst:headContributions xhtml="true" categoryIncludes="headerNav" />




<hst:headContributions xhtml="true" categoryIncludes="styles" />


但是该插件的标题没有使用任何类别。

在我的JSP模板中添加以下行可解决此问题:

<hst:headContributions xhtml="true" categoryExcludes="headerNav,styles" />

08-03 22:20