且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么Facebook返回错误的页面(影响Facebook Like和Share URL)?

更新时间:2023-12-02 17:45:46

确定这是您的Open Graph类型的问题。

 < meta content =websiteproperty =og:type/ &GT; 

Per 文档


使用文章对于
表示短暂内容的任何URL,例如
a新闻文章,博文,照片,
视频等。不要使用网站
这个目的。 网站博客
,旨在表示整个网站,
an og:类型标签与类型网站
博客应通常只出现在域的
根上。



When we first put up a blog post, Facebook often (but not always) gets confused about what the page is. Specifically, if you try to use the Like button on the blog page OR if you try to share via the Share link on your profile, Facebook will see the root blog page rather than the actual post page.

For example, we recently posted: http://thisorthat.com/blog/2010-song-of-the-year-round-1-results

If the user "likes" it, it returns the title for: "http://thisorthat.com/blog"

When you run the post URL through the FB Linter, you can see the problem. "http://developers.facebook.com/tools/linter?url=http://thisorthat.com/blog/2010-song-of-the-year-round-1-results"

In the Debug section it shows an extra og:title, og:url, description and og:image (the last 4 rows of the Debug section). This is the meta data from the root directory. What we cannot figure out is why. Why is Facebook seeing the correct meta data on the page and then also pulling the meta data from the root directory (and using that incorrectly to populate the data for the Like button and the Share URL tool)?

One other oddity. FB "figures it out" after a few days. Of course, by that time relatively few people are viewing the post.

UPDATE -- I want to thank Peter Bailey again for his answer, but we also discovered that there was another issue that we had to resolve before the Like button worked.

The issue was that we were displaying the Facebook the Like button on a post that was not yet published. The problem with this is that FB then can't resolve the URL and "guesses" as to the correct URL. In our case, it always guesses thisorthat.com/blog. Unfortunately, it then caches that guess for a number of days and that cache cannot be cleared by the Linter. So the ultimate solution was to both fix the og:type as Peter suggested, but also to remove the Like button from the blog post preview. It's very important that you don't show FB a page before it's published or if you do, change the URL.

Pretty sure it's your Open Graph type that's the problem.

<meta content="website" property="og:type"/>

Per the documentation

Use article for any URL that represents transient content - such as a news article, blog post, photo, video, etc. Do not use website for this purpose. website and blog are designed to represent an entire site, an og:type tag with types website or blog should usually only appear on the root of a domain.