I'm using Hippo CMS.
After unsuccessfully using HST SEO support plugin, I realised that HstResponse::addHeadElement
did not have any effect on my HTML pages.
For instance, when adding the following lines in a component's code:
Element title = response.createElement("title");
title.setTextContent("Foo");
response.addHeadElement(title, "hst.seo.document.title");
I would expect the corresponding <title>Foo</title>
markup to be included in the response, but it is not.
What did I miss?
The problem is that I didn't have an appropriate hst:headContributions
node in the layout file.
I had two of them for two different categories:
<hst:headContributions xhtml="true" categoryIncludes="headerNav" />
and
<hst:headContributions xhtml="true" categoryIncludes="styles" />
But the plugin doesn't use any category for its head contributions.
Adding the following line in my JSP template fixed the issue:
<hst:headContributions xhtml="true" categoryExcludes="headerNav,styles" />