itemtype必须是完整HTTPS URL,不能缩写或省略协议;需与itemscope同层共存,指向可访问且返回200的schema.org等权威词汇表地址,如https://schema.org/Product。

itemtype必须是完整 HTTPS URL,不能缩写或省略协议
itemtype不是随便填的字符串,它必须指向一个可验证的、外部定义的词汇表地址。主流解析器(包括 Google Rich Results Test)只认 https://schema.org/ 开头的绝对 URL,且协议必须是 https,不能是 http 或协议相对路径(//schema.org/Person)。
常见错误包括:
-
itemtype="Person"—— 缺少 URL,纯字符串无效 -
itemtype="http://schema.org/Person"—— HTTP 协议已被拒绝 -
itemtype="https://schema.org/Person/"—— 末尾斜杠非法(官方文档明确要求无尾部斜杠) -
itemtype="./vocab#Product"—— 相对路径,无法被外部解析器访问
✅ 正确写法:itemtype="https://schema.org/Product"、itemtype="https://schema.org/LocalBusiness"
itemtype必须和itemscope成对出现在同一元素上
单独写 itemscope 或单独写 itemtype 都不会触发微数据解析。它们必须共存于同一个容器元素,表示“这里是一个实体,类型是 XXX”。
立即学习“前端免费学习笔记(深入)”;
这个容器推荐用语义化标签,比如 <article></article>、<section></section> 或 <div>,但不能是空标签或文本节点。
<p>错误示例:<br><code><div itemscope><span itemtype="https://schema.org/Person">张三</span></div> —— itemtype 没和 itemscope 同层,无效<p itemscope></p><div class="aritcle_card flexRow">
<div class="artcardd flexRow">
<a class="aritcle_card_img" href="/xiazai/skill10828" title="财经HTML高端海报生成"><img
src="https://img.php.cn/upload/skill/001/246/273/6adaf20dbae7c507.jpg" alt="财经HTML高端海报生成" ></a>
<div class="aritcle_card_info flexColumn">
<a href="/xiazai/skill10828" title="财经HTML高端海报生成">财经HTML高端海报生成</a>
<p>复杂得财经如何变成清晰,适合手机看的海报?如何加上你的IP</p>
</div>
<a href="/xiazai/skill10828" title="财经HTML高端海报生成" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span> </a>
</div>
</div> —— 空元素,无内容可绑定属性,Google 可能忽略
不同类型对应不同itemtype,选错会导致属性失效
schema.org 的类型之间有严格契约关系。比如 itemprop="price" 只在 https://schema.org/Offer 或 https://schema.org/Product 下合法;如果写在 https://schema.org/Person 里,Google 工具会直接报错:“Property price is not a valid property of Person”。
选 type 的关键不是“越细越好”,而是匹配页面核心意图:
- 企业首页展示地址、电话、营业时间 → 用
https://schema.org/LocalBusiness - 单篇博客文章 → 用
https://schema.org/Article - 餐厅菜单项 → 用
https://schema.org/FoodEvent或https://schema.org/MenuItem,而非硬套Product
查类型最稳妥的方式是直访 https://schema.org/,点进目标类型页,看 “Properties” 列表是否包含你要用的 itemprop 名。
itemtype URL 必须能返回 HTTP 200,哪怕内容只是 HTML 页面
WHATWG 规范和 Google 工具都要求:itemtype 值对应的 URL 在 HTTP 层必须可访问且返回 200 状态码。这不是要你部署一个 JSON-LD 接口,而是指该 URL 至少能被浏览器打开(比如 https://schema.org/Product 确实返回一个 HTML 页面)。
这意味着:
- 自建词汇表 URL(如
https://yoursite.com/vocab#Person)必须真实存在并返回 200,否则结构化数据会被丢弃 - 本地开发时若用
file://或localhost路径,Google 工具无法验证,会提示“URL unreachable” - 重定向(301/302)到有效地址通常可以,但不建议——增加失败风险
验证前务必用 Google Rich Results Test 实时抓取你的页面,它会明确告诉你哪个 itemtype URL 不可达或格式错误。


















