应使用https://schema.org/searchaction,但必须嵌套在website或webpage中,通过itemprop="potentialaction"关联,且target和query-input为必需字段。

itemtype 应该用 Schema.org 的哪个类型?
搜索功能不是独立实体,不能直接套用 WebSite 或 Organization。正确做法是用 SearchAction —— 它专为“用户发起搜索”这一动作建模,且必须嵌套在 WebSite 或 WebPage 的结构中才合法。
常见错误是单独给搜索框加 itemtype="https://schema.org/SearchAction",这会导致结构化数据验证失败(Google Rich Results Test 会报 “Missing field ‘target’”)。SearchAction 必须有 target、query-input 两个必需字段,且依赖父级 itemscope。
如何嵌套 itemscope / itemtype 实现合规标记?
必须两层嵌套:外层声明网站主体(WebSite),内层在搜索表单上声明动作(SearchAction)。关键点是 itemprop="potentialAction" 这个桥梁属性,它把动作挂载到网站上。
<div itemscope itemtype="https://schema.org/WebSite">
<meta itemprop="url" content="https://example.com/">
<form itemprop="potentialAction" itemscope itemtype="https://schema.org/SearchAction">
<meta itemprop="target" content="https://example.com/search?q={search_term_string}">
<input itemprop="query-input" name="q" type="text" required>
</form>
</div>
-
target值必须是完整 URL,且含{search_term_string}占位符(大小写敏感,不可写成{query}) -
query-input必须绑定到实际输入框的name属性(如name="q"),否则 Google 不识别 - 不要用
id或class模拟输入框;<input>或<textarea></textarea>是唯一支持的元素
为什么用 meta 标签写 target 而不用 form action?
因为 target 在 Schema 中定义为 “可执行的 URL 模板”,不是运行时跳转地址。用 <meta> 显式声明,能确保结构化数据解析器准确提取模板格式;而 form action 是浏览器行为控制,对搜索引擎无意义,还可能因 JS 动态修改导致不一致。
另一个坑:如果网站搜索走 POST 请求,SearchAction 仍要求 target 是 GET 风格 URL 模板(例如 /search?q={search_term_string})。POST 本身无法被搜索引擎预演,所以 Schema 规范只支持 GET 场景。
验证通过但没触发富摘要?检查这三点
Google 支持 SearchAction,但仅用于“站内搜索建议”(如你在 Google 搜索 site:example.com 后,下拉提示“搜索 example.com”),不会因此生成独立搜索框富结果。真正影响的是移动端 Google App 的快捷搜索入口。
- 确保页面是首页(
WebSite类型通常只在首页使用),子页面用WebPage+potentialAction可能被忽略 - 检查
targetURL 是否可公开访问且返回 200(若重定向到登录页或 404,Google 会丢弃该标记) - 占位符必须严格为
{search_term_string}—— 多一个空格、换行或用中文括号都会导致解析失败,且错误不报在验证工具里,只静默失效
最常被忽略的是占位符拼写和 target 的协议一致性:如果页面是 https,target 也必须是 https,混用 http 会被视为无效模板。
前端入门到VUE实战笔记:立即使用
在学习笔记中,你将探索 前端 的入门与实战技巧!











