Set HTML content in meta tags at headcontribution


How can I fetch the html content for meta tag? I tried as below but getting org.hippoecm.hst.content.beans.standard.HippoHtml@d56b945c and not the html content.
I am expecting the data present in rich text editor field.

<@hst.headContribution category=“htmlHead”>
< meta property=“og:description” content="<@htmlBlock html=document.body/>"/>
< /@hst.headContribution>


Hello Bharat,

From the snippet you have provided I can see you are using an htmlBlock macro which of course I don’t know what it does.

However, the recommended way to render HTML content is by using the <@hst.html…/> tag.
You can read about the tag and the parameters it accepts here section hst-core-tags:html
(the link is for v13 *if you are using older version simply search for the according version)

HTH and kind regards,

Thanks Lef.
Actually htmlBloack macro is assigned with @hst.html only. So, it is as below.

<@hst.headContribution category=“htmlHead”>
<meta property=“og:description” content="<@hst.html hippohtml="${document.body}" /> "/>
< /@hst.headContribution>

If I am implementing the same to fetch html data on my webpage instead at meta tag, it works properly.
<@hst.html hippohtml="${document.body}" />

Hello Bharat,

the cause of the problem is that the result of the <@hst.html…/> is not a plain string but markup something which is not allowed to be in the content of a meta tag.

The error message I got when I reproduced your use case :

The value of attribute “content” associated with an element type “meta” must not contain the ‘<’ character.

I would recommend using a suitable field (string) for this purpose and not try to clean the output of the tag.

Kind regards,

I agree with using a simple text field but with not cleaning the output of the tag. If your editors can be trusted then cleaning the tag is not a problem. If they can’t be it is a necessity. I can see no good case for allowing any random string. such as

"/><script>malicious code</script>