itemtype 属性必须是绝对 url,如 https://schema.org/restaurant;相对路径、短名称、http 协议或协议相对 url 均无效,且必须与 itemscope 成对出现在同一元素上。

itemtype 属性必须是绝对 URL
HTML 中的 itemtype 不接受相对路径、短名称或本地标识符,比如 itemtype="Person" 或 itemtype="./schema.org/Person" 都是无效的。它只认完整的、可解析的 HTTP/HTTPS URL,最常见的是 https://schema.org/Person 这类。
浏览器不会报错,但结构化数据工具(如 Google Rich Results Test)会直接忽略整个 itemscope 块 —— 你写了等于没写。
- ✅ 正确:
itemtype="https://schema.org/Restaurant" - ❌ 错误:
itemtype="Restaurant"(缺少协议和域名) - ❌ 错误:
itemtype="http://schema.org/Restaurant"(HTTP 已不被多数工具支持,优先用 HTTPS) - ❌ 错误:
itemtype="//schema.org/Restaurant"(协议相对 URL 不被识别)
验证 itemtype 是否被正确解析
光看 HTML 源码没法确认是否生效,得靠外部工具抓取并解析 DOM 后的结果。手动检查时,别只盯着属性值是否“看起来像 schema”,要确认它是否被当成有效 URI 处理。
- 打开 Google Rich Results Test 或 Schema Markup Validator
- 粘贴 HTML 片段或输入线上 URL,提交后看「Detected structured data」区域有没有列出你的类型
- 如果显示
No structured data detected,大概率是itemtypeURL 格式不对,或外层缺少itemscope - 注意:这些工具不校验 URL 是否真实可访问(比如拼错成
https://schema.org/Restaruant也不会报错),只校验语法格式
itemtype 和 itemscope 必须成对出现
itemtype 单独存在毫无意义 —— 它必须和 itemscope 在同一个元素上,否则解析器不会启动微数据解析流程。
将调研报告、方案对比、数据分析、需求梳理、会议纪要、设计说明、代码评审、学习笔记等任务产物输出为可在浏览器直接打开的单文件 HTML,替代 Markdown 作为最终交付物。Markdown 在信息密度、视觉清晰度和可分享性上已跟不上 AI 产物的丰富度,HTML 能同时承载排版、表格、SVG 等。
常见疏漏是把 itemscope 写在父容器、itemtype 写在子元素,例如:
<div itemscope> <span itemtype="https://schema.org/Organization">公司名</span> </div>
这样 itemtype 完全无效。正确写法是:
<span itemscope itemtype="https://schema.org/Organization">公司名</span>
-
itemscope是开关,itemtype是类型声明,二者缺一不可 - 可以省略
itemtype(仅用itemscope表示匿名 item),但不能只有itemtype没有itemscope - 嵌套 item 时,每个
itemscope元素都可以有自己的itemtype,互不影响
注意 schema.org 的重定向和旧版 URL
schema.org 本身会做 301 重定向,比如 http://schema.org/Person 会跳转到 https://schema.org/Person,但部分解析器(尤其是较老的爬虫或测试工具)可能不跟随重定向,导致识别失败。
- 始终使用
https://schema.org/...开头,不要用http - 避免使用已废弃的旧命名空间,如
http://data-vocabulary.org/Person(Google 自 2016 年起停止支持) - 注意大小写:schema.org 类型名首字母大写,
https://schema.org/Event有效,https://schema.org/event无效 - URL 中不能有多余空格或不可见字符(复制粘贴时容易带入零宽空格)
itemscope 缺失这两个点。只要确保两者同时存在且 URL 完整可解析,后续的 itemprop 才有作用基础。前端入门到VUE实战笔记:立即使用
在学习笔记中,你将探索 前端 的入门与实战技巧!










