HTML5 的开放图验证 [英] Open Graph validation for HTML5

查看:26
本文介绍了HTML5 的开放图验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以让 facebook 糟糕的 Open Graph 元标记来验证我的文档类型是否为 <!DOCTYPE html> (HTML5)?

Is there any way to get facebook's crappy Open Graph meta tags to validate if my doctype is <!DOCTYPE html> (HTML5)?

除了 facebook 的 Open Graph 元标记外,我的文档可以完美验证.

Other than facebook's Open Graph meta tags, my document validates perfectly.

我真的不想用 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> 因为这会产生一系列全新的问题.

I really don't want to use <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> as that creates a whole new set of problems.

这是有问题的验证错误之一的示例...

Here is an example of one of the validation errors in question...

错误第 11 行,第 47 列:此时元素元不允许属性属性.

Error Line 11, Column 47: Attribute property not allowed on element meta at this point.

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

任何帮助将不胜感激...我一直在寻找几天无济于事.

Any help would be appreciated... I have been searching off and on for days to no avail.

推荐答案

对于 HTML5,将此添加到您的 html 元素 就像在 ogp.me 上描述的那样 并保留您的 og: 前缀属性:

For HTML5, add this to your html element like described on ogp.me and keep your og: prefixed properties:

<!doctype html>
<html prefix="og: http://ogp.me/ns#">
<head>
     <meta property="og:type" content="website" />
     ...

<小时>

对于 XHTML(如 OP 的问题),使用 name 属性而不是 property 属性.Facebook lint 会发出警告,但仍会识别和解析元值.


For XHTML (like OP's question), use the name attribute instead of property attribute. Facebook lint will throw a warning, but the meta value will still be recognized and parsed.

<meta name="og:title" content="Hello Facebook" />

这篇关于HTML5 的开放图验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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