itemtype必须配合itemscope使用才生效,单独声明无效;itemscope开启微数据解析,itemtype指定schema类型,嵌套结构需逐层声明itemscope,且所有url须为https://schema.org/开头。

itemtype 必须配合 itemscope 使用才能生效
单独写 itemtype 没有任何结构化数据效果。浏览器和搜索引擎只认带 itemscope 的容器——它才是开启微数据解析的开关。常见错误是只加 itemtype="https://schema.org/Place" 却漏掉 itemscope,结果 Google Rich Results Test 完全不识别。
正确写法必须是:
<div itemscope itemtype="https://schema.org/Place"> <span itemprop="name">西湖</span> </div>
-
itemscope告诉解析器:从这里开始是一个独立实体 -
itemtype指定这个实体属于哪个 Schema 类型(https://schema.org/Place是唯一推荐值,别用旧的http://schema.org/Place) - 所有
itemprop属性都只能在该itemscope范围内生效
地点常用属性要用 itemprop 显式标注
仅声明 itemtype="https://schema.org/Place" 不会自动提取页面文本。每个字段必须用 itemprop 明确绑定,否则结构化数据里就为空。比如地址、经纬度、电话这些字段,不加 itemprop 就等于没写。
关键属性示例:
<div itemscope itemtype="https://schema.org/Place">
<h1 itemprop="name">上海中心大厦</h1>
<div itemprop="address" itemscope itemtype="https://schema.org/PostalAddress">
<span itemprop="streetAddress">陆家嘴环路479号</span>
<span itemprop="addressLocality">上海市</span>
<span itemprop="postalCode">200120</span>
</div>
<meta itemprop="latitude" content="31.2335">
<meta itemprop="longitude" content="121.5065">
<span itemprop="telephone">021-5879XXXX</span>
</div>
-
address推荐嵌套PostalAddress类型,避免把整段地址塞进一个itemprop="address" - 经纬度用
<meta>标签 +content属性,不要用可见文本,否则影响可读性 -
telephone值应为纯数字或带国际前缀格式(如+86215879XXXX),避免括号、分机号等非标准字符
嵌套 itemtype 要逐层声明 itemscope
像 address 这种复杂属性,其值本身也是一个结构化对象(PostalAddress),就必须再套一层 itemscope 和对应 itemtype。漏掉内层 itemscope 是最常导致地址字段丢失的原因。
错误写法(内层缺 itemscope):
<div itemscope itemtype="https://schema.org/Place">
<div itemtype="https://schema.org/PostalAddress"> <!-- ❌ 缺 itemscope -->
<span itemprop="streetAddress">xxx</span>
</div>
</div>
正确写法:
<div itemscope itemtype="https://schema.org/Place">
<div itemscope itemtype="https://schema.org/PostalAddress"> <!-- ✅ 有 itemscope -->
<span itemprop="streetAddress">xxx</span>
</div>
</div>
- 每级嵌套类型都要独立声明
itemscope,不能靠外层继承 - 嵌套层级不宜过深(建议 ≤2 层),否则 Google 可能截断解析
- 嵌套时注意
itemprop写在父容器内,而不是子容器的itemtype上
验证时优先用 Google Rich Results Test 而非结构化数据测试工具
Google Structured Data Testing Tool 已停用,现在必须用 Rich Results Test。它对 itemtype 的协议头更敏感:如果用了 http:// 开头的 URL(哪怕只是少了一个 s),会直接报 “Unrecognized type” 错误。
- 确保所有
itemtype值以https://schema.org/开头,大小写严格匹配 - 测试前先检查 HTML 是否合法(如标签闭合、引号配对),语法错误会导致整个微数据块被忽略
- 移动端页面中,如果地点信息被 JavaScript 动态插入,需确认 SSR 或预渲染已包含这些
itemprop标签,否则爬虫抓不到
真正容易被忽略的是嵌套 scope 的边界和协议头的 HTTPS 强制要求——这两处出错,整个地点结构化数据就归零。
前端入门到VUE实战笔记:立即使用
在学习笔记中,你将探索 前端 的入门与实战技巧!











