Author Topic: SocialBaker OpenGraph canonical link not correct  (Read 1053 times)

Offline astricia

  • Posts: 707
  • Gender: Female
    • netSchmiede24
SocialBaker OpenGraph canonical link not correct
« on: November 20, 2018, 03:15:14 PM »
Hi all (esp. Ruud...),

I have SocialBaker (2.9) installed on a website und have the opengraph snippet included in my template.

It seems to work right - BUT I have a blog on that website, built with an OFA module. And when I want to post one of those blog items on Facebook, I did not get the expected headline and image - so I investigated a bit further.

The canonical link (first line of the opengraph output) contains TWICE the page title of my blog (aktuell). so it is:
Code: [Select]
<link rel="canonical" href="https://www.domain.tld/pages/aktuell/aktuell/title.php" />instead of
Code: [Select]
<link rel="canonical" href="https://www.domain.tld/pages/aktuell/title.php" />
Furthermore I put the URL into the Facebook Debugger (https://developers.facebook.com/tools/debug/sharing/), and it said that the following things are missing:#og:url, og:type, og:title, og:image, og:description, fb:app_id

I DO have og:url - but it is the same as the canonical link. I also have title and image - but Facebook is not picking it up. Maybe because of the wrong link in the canonical url ?

Help anyone?

Thanks,
Astrid

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: SocialBaker OpenGraph canonical link not correct
« Reply #1 on: November 20, 2018, 05:09:58 PM »
I just released version 2.10.
https://dev4me.com/modules-snippets/opensource/socialbaker/

The double /pages/ofa-parent/ in the link (canonical and og:url) was a bug (only when not using shorturl) that is fixed in this version.
This new version has a few other bugfixes like special characters handling in page titles.
As extra it ouputs a rich snippet for Bakery product pages with item details and pricing info.

So, just try this version.

I was looking at your website (assuming that was where the problem was) and I noticed you call openGraph() twice.
The first time with the first parameter "true". Your website is not using shortUrl so you should not do that. Facebook will get very confused :-)
Just use the <?php echo openGraph(); ?> call.

You can also use a second parameter that will show the page title (and metadata description, and used language). For OFA/Bakery pages it will use the item-title instead of the parent page title.
When "1" is used, the title will be "Page title - Website title".
"2" will only show the page_title
"3" will show "Website title - Page title".

I would advise to use <?php echo openGraph(false1); ?> in your website.


Offline astricia

  • Posts: 707
  • Gender: Female
    • netSchmiede24
Re: SocialBaker OpenGraph canonical link not correct
« Reply #2 on: November 20, 2018, 05:33:04 PM »
I wasn't actually talking about my own website - but you are certainly right that I need to work on that as well. Just too many clients projects at the moment to take care of my own stuff...

I just updated SocialBaker on the website I am currently working on - and it does fix the canonical link problem, but Facebook is still not scraping the link correctly. So there must be a different issue with it. Can you please take a look? I am trying to scrape this link:

https://www.rechtsanwalt-roesrath.de/pages/aktuell/scheidungs-abc.php

Thanks,
Astrid

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: SocialBaker OpenGraph canonical link not correct
« Reply #3 on: November 20, 2018, 06:00:51 PM »
Ok.. going into error finding mode :-)

If you look at the "See exactly what our scraper sees for your URL" link in the facebook debugger you will see that there are some wrong tags in the <head> of your template.This causes the facebook scraper not correctly seeing the <head> dection of that website.

This is the start of the debugger output:(note the <body? and <p> tags where you should not see them.
Code: [Select]
<!DOCTYPE html>
<html><body>
<p>&#65279;
<!--[if lt IE 7 ]><html class="ie ie6" lang="de"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="de"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="de"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><!--<![endif]-->

</p>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta charset="utf-8">

Looking with the firefox devtools at the result of the html call you see a (non printable) character before the <!DOCTYPE...
Probably this is because your template is saved in "UTF-8 with BOM".
If you use Notepad++ to edit your template you can convert this using the "Encoding" menu to UTF-8 (without BOM).

I cannot be sure just looking from here... but I think that might fix it :-)

Offline astricia

  • Posts: 707
  • Gender: Female
    • netSchmiede24
Re: SocialBaker OpenGraph canonical link not correct
« Reply #4 on: November 20, 2018, 06:28:54 PM »
Perfect, Ruud - thank you. What would I do without all of you here in the forum? :-D

 

postern-length