Can You Have Your OpenGraph Object Link to a Diffe

2019-03-31 04:33发布

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)?

2条回答
Juvenile、少年°
2楼-- · 2019-03-31 05:14

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.

查看更多
我命由我不由天
3楼-- · 2019-03-31 05:31

@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

查看更多
登录 后发表回答