How to add meta property dynamically from freemarker template

Ovidiu David Dan, modified 5 Years ago. New Member Posts: 15 Join Date: 1/23/17 Recent Posts
Hello, I want to add to the head of some pages the meta og:image.  I added this code to my template:
<liferay-util:html-top outputkey="htmltop">
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<meta property="og:image" content="${imagen_destacados.getData()}">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </liferay-util:html-top>
but it doesn´t work.Does anyone have any idee of the reason why it doesn't work for me?

Looking at the documentation I founded this:The Liferay-Util taglib is also available via a macro for your FreeMarker theme templates and web content templates. Follow this syntax:
&lt;@liferay_util["tag-name"] attribute="string value" attribute=10 /&gt;
Is this what i need to put in my template? I tried to put it in my template but it doen't work..
Thanks
Ovidiu David Dan, modified 5 Years ago. New Member Posts: 15 Join Date: 1/23/17 Recent Posts
I managed to do it with <@liferay_util ["html-top"] /> but it works only when browsing between pages. If I access the page directly, I cannot add to the head what I need.
I use Liferay 7.2 that being a SPA application may have to do with this matter
Anyone have any ideas?
Ovidiu David Dan, modified 5 Years ago. New Member Posts: 15 Join Date: 1/23/17 Recent Posts
I finally got it to work correctly with:<@liferay_util["html-top"]>
                   <meta name="image" property="og:image" content="srcImage">
 </@>
Luis Silva, modified 5 Years ago. New Member Post: 1 Join Date: 5/14/20 Recent Posts
Cool, I found myself with the same problem and your answer helped.
Jamie Sammons, modified 3 Years ago. New Member Post: 1 Join Date: 3/23/22 Recent Posts

It's not working for me, someone has other solution?

Jamie Sammons, modified 3 Years ago. New Member Post: 1 Join Date: 4/5/22 Recent Posts

The current version of Liferay includes Open Graph Tags in the layouts. In the layout setup, look for the Open Graph area  five nights at freddy's