Schema站点导航(SiteNavigationElement)是结构化数据类型,需通过JSON-LD嵌入HTML中,不能用纯HTML配置;必须作为WebSite的navigationElement属性存在,且url、hasPart等字段须符合规范。

什么是 Schema 站点导航,它和 HTML 有关系吗
Schema 站点导航(SiteNavigationElement)是结构化数据的一种,用于向搜索引擎说明网站的主导航链接。它本身不是 HTML 属性或标签,不能用纯 HTML 配置——必须通过 JSON-LD 或 Microdata 嵌入 HTML 文档中。常见误区是试图在 里加 itemscope 或 itemtype 就完事,结果搜索引擎完全不识别。
- 必须使用
script type="application/ld+json"块,放在或开头附近 - 不支持内联 HTML 属性方式(比如
-
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"url": "https://example.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "https://example.com/search?q={search_term_string}",
"query-input": "required name=search_term_string"
},
"navigationElement": {
"@type": "SiteNavigationElement",
"name": "Main navigation",
"url": "https://example.com/",
"hasPart": [
{
"@type": "SiteNavigationElement",
"name": "Products",
"url": "https://example.com/products/"
},
{
"@type": "SiteNavigationElement",
"name": "About",
"url": "https://example.com/about/"
}
]
}
}
</script>
-
hasPart数组最多建议 10 项,过多可能被忽略 - 每个子项的
url必须是完整协议+域名(https://...),相对路径无效 -
name应与页面上可见导航文字一致,避免关键词堆砌 - Google Rich Results Test 工具会报错:
The property navigationElement is not recognised by Google for element type WebSite.—— 实际是反过来了:没包裹在WebSite里,navigationElement才不被识别 - 不要用
Organization或LocalBusiness替代WebSite,它们不支持navigationElement字段 - 如果站点有多个导航区(如顶部+侧边栏),可重复定义多个
navigationElement,但每个都需在同一个WebSite对象下 -
url字段缺失或值为空字符串 → Google 直接跳过整个块 -
hasPart里混用了非SiteNavigationElement类型(比如写了"@type": "LinkRole")→ 解析中断 - 页面实际返回 HTTP 状态码不是 200(例如重定向到带参数的 URL)→ 即使 JSON-LD 正确,Google 也可能无法抓取并解析
为什么用
WebSite包裹SiteNavigationElementSiteNavigationElement是一个“组件”,不能独立存在;Schema 规范要求它必须作为WebSite的navigationElement属性出现。直接写顶层@type: "SiteNavigationElement"会导致结构校验失败。验证失败的三个高频原因
真正起作用的不是 HTML 结构,而是这段 JSON-LD 是否能被 Googlebot 加载、解析、关联到当前页面 URL。别花时间美化
的 class 名,优先确保 script 块可执行、无 JS 错误、无 CSP 阻断。 -
前端入门到VUE实战笔记:立即使用
在学习笔记中,你将探索 前端 的入门与实战技巧!











