Diferent Open Graph tags for Homepage and article

Discuss Search Engine Optimization in relation to Joomla! 3.x. This forum will also have discussions on SEF/SEO Joomla! 3.x extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
User avatar
CyrusXxX
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 236
Joined: Wed Oct 04, 2017 6:23 am
Location: Belgrade Serbia
Contact:

Diferent Open Graph tags for Homepage and article

Post by CyrusXxX » Tue Nov 28, 2017 1:05 am

Hello I have one question concerning open graph tags.
I have implemented Facebook open graph tags for my articles creating template override and inserting this code:

Code: Select all

//opengraph
if (isset($images->image_intro) and !empty($images->image_intro))
{
$timage= htmlspecialchars(JURI::root().$images->image_intro);

}

elseif (isset($images->image_fulltext) and !empty($images->image_fulltext))
{
$timage= htmlspecialchars(JURI::root().$images->image_fulltext);
}
else
{
$timage= 'https://xxxxx.jpg';
}
$doc =& JFactory::getDocument();
$doc->addCustomTag( '<meta name="twitter:title" content="'.$this->escape($this->item->title).'">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@xxxxxxx">
<meta name="twitter:creator" content="@xxxxxxxxx">
<meta name="twitter:url" content="'.str_replace('" ','"',JURI::current()).'"="">
<meta name="twitter:description" content="'.strip_tags($this->item->introtext).'">
<meta name="twitter:image" content="'.$timage.'">
<meta property="og:title" content="'.$this->escape($this->item->title).'"/>
<meta property="og:type" content="article"/>
<meta property="og:email" content="xxxxxxxxxx";/>
<meta property="og:url" content="'.str_replace('" ','"',juri::current()).'"="">
<meta property="og:image" content="'.$timage.'"/>
<meta property="og:site_name" content="xxxxxxxxxx"/>
<meta property="fb:admins" content="xxxxxxxx"/>
<meta property="og:locale" content="xxxxxx" />
<meta property="og:description" content="'.strip_tags($this->item->introtext).'"/>
');
?>
and with this code article meta is displayed properly.
But now if I insert in meta property image for main domain in template head section that image overrides article image set in default.php template override.

Can anyone tell me how to set open graph image for main domain and not to override articles image when shared?

Thank you!

User avatar
CyrusXxX
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 236
Joined: Wed Oct 04, 2017 6:23 am
Location: Belgrade Serbia
Contact:

Re: Diferent Open Graph tags for Homepage and article

Post by CyrusXxX » Wed Nov 29, 2017 8:10 am

Solved.
Solution was to add similar code to template overides for blog and feutured.

djrudyn
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Nov 06, 2017 8:16 pm

Re: Diferent Open Graph tags for Homepage and article

Post by djrudyn » Wed Oct 10, 2018 1:30 pm

Hi,
I am busy trying to do this on my joomla site (Joomla version, 3.8.13).
I am new to Joomla and web-design - can you please give me more details on how to do this

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3507
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Diferent Open Graph tags for Homepage and article

Post by ribo » Wed Oct 10, 2018 1:46 pm

djrudyn wrote:
Wed Oct 10, 2018 1:30 pm
Hi,
I am busy trying to do this on my joomla site (Joomla version, 3.8.13).
I am new to Joomla and web-design - can you please give me more details on how to do this
Check how you do it https://docs.joomla.org/How_to_override ... omla!_core
chat room spontes : http://www.spontes.com


Locked

Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 3.x”