Is it possible to extract metadata from fetched url instead of canonical url?
Asked Answered
H

2

2

I have a Facebook like that links to a page on witch I don't have complete control: I can modify the <body> but not the <head> of the page... So I tried to set the link of the like button on a new page on which I have complete control, set the opengraph metatags on this page, and set an og:url that links to the original page.

But in the end Facebook tries to extract metadata from the og:url and overrides the metatags of the previous page... Is it possible to tell that I want to scrape metadata from the first fetched url and not from the og:url ?

Hake answered 5/4, 2012 at 9:4 Comment(0)
C
5

There is no way to instruct linter to extract OpenGraph metadata from page which have URL different than one defined in og:url.

Linter will always extract the meta tags from URL defined in og:url at the end of the chain...

There is a way to do something other (which may, or may not fit your needs):

You can create intermediate page that will have all the required OpenGraph including og:url pointing to that page (not the one you have no control over it). That page will only have meta-data and JavaScript/Meta redirect to the final page, so user who land this intermediate page will be redirected to the correct final page.

Beware, this will associate all the likes not to the "final" page but to the intermediate one.

Castellated answered 5/4, 2012 at 9:16 Comment(2)
Thanks, nice solution! I've just putted the javascript redirect in the first middle page and it works... I know it would be better to put metadata in the head of the final page, but till the day I'll have no access to the <head> is ok!Hake
Thank you, good sir. This works perfectly for Javascript single page applications. Facebook's crawler wasn't getting the right info since the page renders dynamically on the client side with Javascript and the crawler simply parses the html shell file served by the server. Using this technique, I made a server side call that renders the meta tags the way I need them and eventually client-side redirects to my Javascript single page web app. Works exactly the way I need it to. Thanks again!Towner
D
0

I think there is a bug in the Facebook Debug/linter, with regards to which URL can have the OG metadata. Your OG:URL should be canonical, which means this is the URL that should work today, tomorrow, and in ten years from now. Where as the url that was shared is temporal, and web developers can't guarantee that the "fetch" url will persist. Your canonical / og:url might redirect to the final destination that has og: tags.

But, the bug in the FaceBook linter is that its not following redirects past the og:url. i.e. http://example.com/persistant/123 where as that might just redirect to the friendly URL, such as http://example.com/year/month/title/persistant_123 . Perhaps someone from FaceBook can clarify their interpretation of "shall redirects be followed from the canonical URL".

Google's Opinion Google Webmaster Blog: Specify your Canonical

Can rel="canonical" be a redirect? Yes, you can specify a URL that redirects as a canonical URL. Google will then process the redirect as usual and try to index it.

Current FaceBook Debug/Linter practice is to stop once its reached the OG:URL, and not follow standard HTTP redirects to get to the OG tags. I think Google's definition of Canonical is more, well.. canonical of what web developers are expecting.

Dorina answered 26/4, 2012 at 19:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.