og-metatag not rendered correctly

  • Steven Trooster
  • Steven Trooster's Avatar Topic Author
  • Offline
  • Senior Member
7 months 2 weeks 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:

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: )

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: 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
7 months 2 weeks 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:

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory:

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

Powered by Kunena Forum