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

故事扮演 提交于 2019-12-20 04:23:33

问题


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 ?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/10025687/is-it-possible-to-extract-metadata-from-fetched-url-instead-of-canonical-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!