Opengraph符合W3C标准吗?

9
我想知道opengraph标记是否符合W3C规范,当我尝试验证时,会出现以下错误:
Line 14, Column 17: there is no attribute "PROPERTY"
 <meta property="og:site_name" content="sitename">

如果这个不合法,会影响我的页面排名和其他搜索引擎算法吗?

是否有可能隐藏这些属性?

5个回答

16

在普通的HTML文档类型中,它不是有效的,但是有一个文档类型可以用来验证包括Open Graph在内的XHTML文档:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">

请看这个问题:属性属性的HTML验证错误


3
不,这就是为什么验证器会报告错误的原因。

2

这似乎可以工作:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="http://rdf.data-vocabulary.org/#">

2

<html version="HTML+RDFa 1.1" lang="en"> <head> <title>示例文档</title> </head> <body> <p>已移动至 <a href="http://example.org/">example.org</a>.</p> </body> </html>


1
通过这个,您正在解决问题:
<!DOCTYPE html>
<html vocab="http://www.w3.org/2011/rdfa-context/rdfa-1.1">

使用这个功能,您可以在HTML中像这样使用行:

<meta property="og:title dc:title" content="m.clinic.pt - Está em boas mãos!">

或者从其他列出的词汇表(http://www.w3.org/2011/rdfa-context/rdfa-1.1)中选择,例如:

cat:        http://www.w3.org/ns/dcat#
qb:         http://purl.org/linked-data/cube#
grddl:      http://www.w3.org/2003/g/data-view#
ma:         http://www.w3.org/ns/ma-ont#
owl:        http://www.w3.org/2002/07/owl#
rdf:        http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfa:       http://www.w3.org/ns/rdfa#
rdfs:       http://www.w3.org/2000/01/rdf-schema#
rif:        http://www.w3.org/2007/rif#
rr:         http://www.w3.org/ns/r2rml#
skos:       http://www.w3.org/2004/02/skos/core#
skosxl:     http://www.w3.org/2008/05/skos-xl#
wdr:        http://www.w3.org/2007/05/powder#
void:       http://rdfs.org/ns/void#
wdrs:       http://www.w3.org/2007/05/powder-s#
xhv:        http://www.w3.org/1999/xhtml/vocab#
xml:        http://www.w3.org/XML/1998/namespace
xsd:        http://www.w3.org/2001/XMLSchema#
prov:       http://www.w3.org/ns/prov#
sd:         http://www.w3.org/ns/sparql-service-description#
org:        http://www.w3.org/ns/org#
gldp:       http://www.w3.org/ns/people#
cnt:        http://www.w3.org/2008/content#
dcat:       http://www.w3.org/ns/dcat#
earl:       http://www.w3.org/ns/earl#
ht:         http://www.w3.org/2006/http#
ptr:        http://www.w3.org/2009/pointers#
cc:         http://creativecommons.org/ns#
ctag:       http://commontag.org/ns#
dc:         http://purl.org/dc/terms/
dc11:       http://purl.org/dc/elements/1.1/
dcterms:    http://purl.org/dc/terms/
foaf:       http://xmlns.com/foaf/0.1/
gr:         http://purl.org/goodrelations/v1#
ical:       http://www.w3.org/2002/12/cal/icaltzd#
og:         http://ogp.me/ns#
rev:        http://purl.org/stuff/rev#
sioc:       http://rdfs.org/sioc/ns#
v:          http://rdf.data-vocabulary.org/#
vcard:      http://www.w3.org/2006/vcard/ns#
schema:     http://schema.org/
describedby:http://www.w3.org/2007/05/powder-s#describedby
license:    http://www.w3.org/1999/xhtml/vocab#license
role:       http://www.w3.org/1999/xhtml/vocab#role

你可以通过http://validator.w3.org/http://html5.validator.nu/ 来验证它。

所以不要这样写:

<div vocab="http://schema.org/" typeof="Product">
   <img property="image" src="dell-30in-lcd.jpg" />
   <span property="name">Dell UltraSharp 30" LCD Monitor</span>
</div>

你可以得到这个:
<!-- The schema: prefix is defined in the vocabulary http://www.w3.org/2011/rdfa-context/rdfa-1.1 -->
<div typeof="schema:Product">
   <img property="schema:image" src="dell-30in-lcd.jpg" />
   <span property="schema:name">Dell UltraSharp 30" LCD Monitor</span>
</div>

一些资源 http://www.w3.org/TR/rdfa-primer/ http://manu.sporny.org/2012/mythical-differences/ http://rdfa.info/


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接