Facebook打开图表元标签&有效的HTML [英] Facebook open graph meta tags & valid html

查看:133
本文介绍了Facebook打开图表元标签&有效的HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

属性属性的Html验证错误


根据Facebook使用他们喜欢的按钮和打开的图表元标签,您需要将这样的东西放置到您的html页面。

  meta property =og:titlecontent =The Rock/> 
< meta property =og:typecontent =movie/>
< meta property =og:urlcontent =http://www.imdb.com/title/tt0117500//>
< meta property =og:imagecontent =http://ia.media-imdb.com/rock.jpg/>
< meta property =og:site_namecontent =IMDb/>

他们在玩什么?这是无效的html,属性属性不是,并且从来没有是元标记的属性,所以为什么在地球上使用了Facebook而不是< meta name =og:titlecontent =The Rock/> ;?



我不愿意使用有效的名称而不是财产来尝试我的网站,因为如果我尝试并且在我的网站上不起作用那么任何在我测试时点击的人都会失败。所以...有没有人知道如果我使用'名称'而不是'属性'这将仍然有效?

解决方案

不要忘记,他们也希望你向html标签声明一些模式 - 特别是通过 xmlns:og =http://opengraphprotocol.org/schema/。OG基于 RDFa ,它将额外的属性添加到元标记中。 p>

一旦你完成了,一定要添加你的fb:like - < fb:like href =http://开发人员。 facebook.com/width =450height =80/> - 例子非常简单,不要忘了添加 xmlns:fb =http://www.facebook.com/2008/fbml否则你会伤心



找到这个答案关于元标记的验证。做这个答案描述应该让你通过任何w3c验证器。


Possible Duplicate:
Html validation error for property attribute

According to facebook to use their like button and the open graph meta tags you need to place something like this into your html page.

<meta property="og:title" content="The Rock"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
<meta property="og:site_name" content="IMDb"/>

What the hell are they playing at? This is invalid html, the attribute 'property' is not and never has been an attribute of the meta tag so why on earth have facebook used this instead of <meta name="og:title" content="The Rock" />?

I am reluctant to try on my site live with valid 'name' instead of 'property' because if I do try and it doesn't work on my site then anyone who clicks like while i am testing it out will have their like fail. So ... Does anyone know if I use the use 'name' instead of 'property' will this still work?

解决方案

Don't forget that they also want you to declare some schemas to the html tag - specifically the open graph one via xmlns:og="http://opengraphprotocol.org/schema/. OG is based on RDFa which adds the additional attributes to the meta tags.

Once you're done with that, be sure to add your fb:like - <fb:like href="http://developers.facebook.com/" width="450" height="80"/> - the example is pretty straightforward. Don't forget to add xmlns:fb="http://www.facebook.com/2008/fbml" otherwise you will be sad

Found this answer on SO regarding validation of the meta tag. Doing what that answer describes should give let you pass it through any w3c validator.

这篇关于Facebook打开图表元标签&amp;有效的HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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