应该将og:image和og:url放入< meta>或< link&gt ;?? [英] Should og:image and og:url put in <meta> or <link>?

查看:175
本文介绍了应该将og:image和og:url放入< meta>或< link&gt ;??的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于 og:image og:url ,因为它们有URL,我可以将它们放在 link 标记而不是 meta 标记,这是否可取?

For og:image and og:url, since they have URL, can I place them in a link tag instead of a meta tag, and is it preferable?

使用这两个标签wrt有什么不同? og:image og:url

Also what is the difference in using these two tags w.r.t. og:image and og:url?

推荐答案

我不知道OGP的其他主要消费者,所以这可能不会成为您的案例的问题,但是如果您打算在Facebook上实施它,那么

I don't know about other major consumers of the OGP so this might not be a problem for your case, but if you plan to implement it for Facebook,

使用打开图形调试器并摆弄 og:标签,看起来Facebook只会识别它们放置在< meta> s。

Doing a quick live test with the open graph debugger and fiddling with the og: tags, it appears that facebook only recognizes them if they are placed in <meta>s.

如果您在< head> 中创建了一个空的HTML文件,其中包含一个 og:url 部分,将其上传到任何URL并通过上面的调试器运行它们,两者都是

If you create an empty HTML file with a single og:url tag in its <head> section, upload it to any URL and run it through the debugger above, both

<link rel="og:url" href="http://www.imdb.com/title/tt0117500/" />

<link property="og:url" content="http://www.imdb.com/title/tt0117500/" />

编辑或者按照评论建议

<link property="og:url" href="http://www.imdb.com/title/tt0117500/" />

将无法解析并返回原始网址,而

will fail to parse and return the original URL, while

<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" /> 

正确解析并返回The Rock on IMDb的内容。在一天结束时,语义很好,但工作代码更好。

parses correctly and returns the contents of The Rock on IMDb instead. At the end of the day semantics are nice, but working code is even better.

这篇关于应该将og:image和og:url放入&lt; meta&gt;或&lt; link&gt ;??的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆