Keyword

og-metatag not rendered correctly

  • Steven Trooster
  • Steven Trooster's Avatar Topic Author
  • Offline
  • Senior Member
More
2 months 6 days ago #169027 by Steven Trooster
Steven Trooster created the topic: og-metatag not rendered correctly
I've added meta tags to a template override to have OG-metatags for Facebook and Twitter in the rendered page of an (K2) article. For safety reasons it is advised to escape the title tag. So my code is:
$document->addCustomTag('<meta property="og:title" content="'.$this->escape($this->item->title).'">');

This will create a tag that looks like this, where the title of the page is Ugenda's festivaloverzicht :
<meta property="og:title" content="Ugenda&amp;#039;s festivaloverzicht">

See an example here: https://www.ugenda.nl/agenda/festivals

Note that the title has the wrong encoding for the apostrophe. It should be ' or '.
So Facebook doesn't recognize the titel correctly and it shows the encoding instead of the apostrophe. (See: https://www.facebook.com/Ugenda/posts/10156534292767719 )

Am I escaping the item->title falsely? Or is there no need to escape it? (And what about security?)

Note that in pages in the eventlist part of our site, the og-tag is rendered correctly. See for example: https://www.ugenda.nl/agenda/event/102529-battlefield-fietstour-de-bevrijding-van-nijmegen where the tag is:
<meta property="og:title" content="Battlefield Fietstour 'De bevrijding van Nijmegen'">
and the code:
$document->addCustomTag('<meta property="og:title" content="'.$this->escape($this->item->title).'">');

Please Log in or Create an account to join the conversation.

  • Fotis
  • Fotis's Avatar
  • Away
  • Administrator
  • JoomlaWorks Support Team
More
2 months 5 days ago #169037 by Fotis
Fotis replied the topic: og-metatag not rendered correctly
K2 properly adds opengraph tags for Facebook and Twitter. You don't need to do that. If you did not see the meta tags in your source, perhaps some other (system) plugin is stripping them up.

See the source code here for example: demo.getk2.org/item


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

Please Log in or Create an account to join the conversation.

Moderators: william white