Can You Have Your OpenGraph Object Link to a Different URL?

半城伤御伤魂 提交于 2019-12-21 05:09:16

问题


So you need a public URL with meta tags to represent an object in the OpenGraph, and one of the required meta tags is a URL property. When the action gets published, it links to this URL property.

Let's say I'm on http://mysite.com/A. It seems like I can't then do this:

<meta property="og:url" content="http://mysite.com/B"></meta>

Because Facebook will try to look at the root url for the meta tags. Is there any way to link to a different URL (mysite.com/B) from a given OpenGraph object URL (mysite.com/A)?


回答1:


You should be able to link to another URL. But all an og:url means is "go over to that URL and use the tags from there instead". You can either

1) put all your tags on A and then redirect users to B with JavaScript or User-Agent detection;

2) put your content on A and do an og:url to B.




回答2:


@Paul, I didn't fully understand or appreciate your comment until now - apologies and thanks.

What I learned from a little more tinkering is that on the initial post to FB with the object item url in the post, is that FB then crawls that page, gets the META tags and if you've got og:url defined it will crawl it again. It crawls it twice.

In my case, I am passing a querystring that does get parsed, but I was not setting it again in the og:url, so when it crawled my page the second time, it was not picking up the querystring variable I needed it to.

That was a dumb thing on my part. Thanks for the great answer.

Jim



来源:https://stackoverflow.com/questions/7561071/can-you-have-your-opengraph-object-link-to-a-different-url

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