Page 1 of 2

[SOLVED] Canonical url - problem with Facebook Sharing Debugger

Posted: Thu Jul 14, 2022 7:46 am
by c0mp0ser
Hi

I have a problem. Facebook Sharing Debugger points to the canonical url as the home page, no matter what url you specify in the debugger form. After analyzing the input URL it shows correctly, but the canonical url - og:url Meta Tag is the home page address and its title, content, image, etc.

What can be done about it?

The Open Graph tags of the theme use the code below as og:url and twitter:site

Code: Select all

<?= $this->url() ?>
I added to <head> the code below but it doesn't change anything:

Code: Select all

<link rel="canonical" href="<?= $this->url() ?>"/>
A two websites tested on commercial hosting ...

BTW: I scraped the www.wondercms.com/about with the same result ‼️

Help, please ... 😔

Re: Canonical url - problem with Facebook Sharing Debugger

Posted: Sun Jul 17, 2022 7:17 pm
by nox
Hi c0mp0ser,

not sure if I understand completely, so please let me know if I missed your quesiton. I did a quick OpenGraph test and it shows the domain name (but not domain-name/about us), image with same filename as page title (there is an issue with titles using spaces) and description:

Code: Select all

<!-- Search Engine Optimization (SEO) -->
<link rel="canonical" href="<?= $this->url() ?>"/>
<!-- HTML Meta Tags -->
<meta name="title" content="<?= $Wcms->get('config', 'siteTitle') ?> - <?= $Wcms->page('title') ?>" />
<meta name="description" content="<?= $Wcms->page('description') ?>">
<meta name="keywords" content="<?= $Wcms->page('keywords') ?>">
<!-- Facebook Meta Tags -->
<meta property="og:url" content="<?= $this->url() ?>" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="<?= $Wcms->get('config', 'siteTitle') ?>" />
<meta property="og:title" content="<?= $Wcms->page('title') ?>" />
<meta property="og:description" content="<?= $Wcms->page('description') ?>" />
<meta property="og:image" content="<?= $Wcms->url() ?>data/files/<?= $Wcms->page('title') ?>.jpg" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta property="twitter:domain" content="<?= $this->url() ?>">
<meta name="twitter:site" content="<?= $this->url() ?>" />
<meta name="twitter:title" content="<?= $Wcms->get('config', 'siteTitle') ?> - <?= $Wcms->page('title') ?>" />
<meta name="twitter:description" content="<?= $Wcms->page('description') ?>" />
<meta property="twitter:image" content="<?= $Wcms->url() ?>data/files/<?= $Wcms->page('title') ?>.jpg" />
No idea how to fix this one:

Code: Select all

content="<?= $Wcms->url() ?>data/files/<?= $Wcms->page('title') ?>.jpg" />
If you upload Home.jpg, About.jpg and so on, it will show a picture, but any title with spaces like Contact us.jpg is an issue (shows only inside a Discord card).

Re: Canonical url - problem with Facebook Sharing Debugger

Posted: Mon Jul 18, 2022 6:38 am
by c0mp0ser
nox wrote: Sun Jul 17, 2022 7:17 pm Hi c0mp0ser,

I did a quick OpenGraph test and it shows the domain name (but not domain-name/about us)
This is the problem I wrote about. Facebook will ALWAYS show a link to the home page, its image and other textual content from it. It should show a link to the current page and its content, eg "domain-name/about". That's NOT how it currently works. As I wrote, this applies even to the official Wonder CMS site.

Re: Canonical url - problem with Facebook Sharing Debugger

Posted: Mon Jul 18, 2022 11:17 am
by nox
I see now, Facebook really displays home page information for all pages. But testing Open Graph meta using online testers (checkers) shows current page (page name, description, image) as it should.

Re: Canonical url - problem with Facebook Sharing Debugger

Posted: Mon Jul 18, 2022 3:36 pm
by nox
This kind of works, but personally I would use it for testing only.
Change:

Code: Select all

<meta property="og:url" content="<?= $this->url() ?>">
to:

Code: Select all

<meta property="og:url" content="<?php echo $_SERVER['REQUEST_URI']; ?>">
Facebook shows title, image and description correctly for the current url.

Re: Canonical url - problem with Facebook Sharing Debugger

Posted: Tue Jul 19, 2022 5:16 am
by c0mp0ser
nox wrote: Mon Jul 18, 2022 3:36 pm I would use it for testing only.
Why for testing only?

Re: Canonical url - problem with Facebook Sharing Debugger

Posted: Tue Jul 19, 2022 6:11 am
by nox
Hey c0mp0ser,

honestly I'm not sure this is the right way to do it.

Code: Select all

<?php echo $_SERVER['REQUEST_URI']; ?>
shows everything after the domain, for example, on Contact page:
https://mywebsite.com/contact

Inside head tag will look like this:

Code: Select all

<meta property="og:url" content="/contact/">

Re: Canonical url - problem with Facebook Sharing Debugger

Posted: Tue Jul 19, 2022 6:21 pm
by c0mp0ser
nox wrote: Tue Jul 19, 2022 6:11 am Hey c0mp0ser,

honestly I'm not sure this is the right way to do it.
What I don't quite understand is why you wrote that "only for testing purposes", if it works fine ...(?) 😉

Re: Canonical url - problem with Facebook Sharing Debugger

Posted: Tue Jul 19, 2022 9:32 pm
by nox
I'm not a programmer or developer, so can't say this is the right way :oops:
Also, not sure what happens if the website is in other languages.
How does the page url looks like...

Re: Canonical url - problem with Facebook Sharing Debugger

Posted: Wed Jul 20, 2022 7:02 am
by c0mp0ser
nox wrote: Tue Jul 19, 2022 9:32 pm I'm not a programmer or developer, so can't say this is the right way :oops:
Also, not sure what happens if the website is in other languages.
How does the page url looks like...
Nevertheless, thank you for your code. It works for me. 👍😉