Open Graph Tags for blog posts and custom module items

What is best practice with Treepl if I want to render Open Graph tags and automatically populated them with values from blog image, title, author etc. In BC we would put the code in a section in the detail/post layout and BC would render it properly in the Head. But this doesn’t work with Treepl.

Ok, it’s actually easy. Data from the module detail layout is as a matter of fact also available in the head, I’ve just checked it. So one can just put something like

<meta property="og:image" content="https://www.yourdomain.com{{this['CustomPropertyForImage']}}>

there and it works. I’m not sure if this always worked like that but I’m certainly happy that it does now.

As an additional note, if you then add an image in the OG field you’ll get duplicate OG Image tags so you might need to have a conditional statement for your custom tag if that’s an issue.

1 Like