北京”工业优选网”是一个大型B2B平台,收录了10万+供应商,月访问量80万。SEO负责人王磊在一次例行测试中发现了一个严重问题——他在ChatGPT中问”找精密加工供应商”时,AI引用的是首页的概述内容,而不是深层页面中具体的供应商详情页。
“首页只有一段200字的平台介绍,真正的供应商数据都在第4层、第5层页面,但AI似乎根本不知道那些页面存在。”王磊用万维网爬虫工具验证发现:原因是导航结构过于复杂——首页 → 行业分类 → 子分类 → 产品列表 → 产品详情,5层导航让AI爬虫无法判断哪个层级的内容更重要。
更糟糕的是,主导航用了JavaScript驱动的下拉菜单,AI爬虫无法正确解析这些菜单结构,导致大量深层页面从未被AI搜索引擎有效索引。
AI搜索引擎的爬虫有”爬取预算”限制——每次访问网站只能爬取有限数量的页面。如果导航结构太深,爬虫会把大量预算花在浏览层级菜单上,而无法到达真正有价值的内容页面。
很多B2B网站为了视觉效果,使用JavaScript驱动的多级下拉菜单、hover触发等交互式导航。但AI搜索引擎的爬虫在JavaScript渲染方面能力有限,可能完全看不到这些菜单中的链接,导致大量页面在AI搜索中”隐形”。
导航不仅要引导用户,还要告诉AI搜索引擎”这个页面在整个网站中的位置”。如果缺少面包屑导航或层级标记,AI无法理解一个”CNC加工详情页”到底属于”精密加工”这个二级分类还是”机加工”这个一级分类。
王磊的方案可以概括为三个核心原则:扁平化结构减少深度、语义化标记传递层级、静态HTML确保可爬取。
首先用技术手段分析当前导航的问题:
from bs4 import BeautifulSoup
import requests
def audit_navigation(url):
"""审计网站导航结构"""
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# 检查导航标签
nav_tags = soup.find_all('nav')
print(f"<nav>标签数量: {len(nav_tags)}")
# 检查JavaScript事件
js_menus = soup.select('[onmouseover], [onclick], [class*="dropdown"]')
print(f"JavaScript驱动的菜单元素: {len(js_menus)}")
# 检查导航深度
nav = soup.find('nav')
if nav:
def get_depth(element, current_depth=0):
depths = [current_depth]
for child in element.find_all(['ul', 'ol'], recursive=False):
depths.extend(get_depth(child, current_depth + 1))
return depths
depths = get_depth(nav)
print(f"导航最大深度: {max(depths)} 层")
# 检查aria-label
aria_labels = soup.select('[aria-label]')
print(f"带aria-label的元素: {len(aria_labels)}")
return {
"nav_tags": len(nav_tags),
"js_menus": len(js_menus),
"max_depth": max(depths) if 'depths' in dir() else None
}
audit_navigation("https://www.gongyexuan.com")
重构导航结构,确保任何页面的最大点击深度不超过3次:
重构前(5层):
首页 → 行业分类 → 子分类 → 产品列表 → 产品详情
重构后(3层):
首页 → 行业分类 → 产品详情页
首页 → 热门产品 → 产品详情页
首页 → 精选供应商 → 供应商主页
核心改动:
– 将”子分类”和”产品列表”合并为带筛选功能的分类页
– 核心产品展示在首页推荐位,减少跳转次数
– 新增”热门搜索”快速入口,直达高频查询的页面
将JavaScript驱动的下拉菜单改为纯CSS方案,确保AI爬虫在不执行JavaScript的情况下也能看到所有链接:
<!-- AI友好的纯CSS导航 -->
<nav aria-label="主导航" class="main-nav">
<ul class="nav-list">
<li class="nav-item">
<a href="/category/machining">精密加工</a>
<ul class="sub-menu" aria-label="精密加工子分类">
<li><a href="/category/cnc">CNC加工</a></li>
<li><a href="/category/lathe">车床加工</a></li>
<li><a href="/category/milling">铣床加工</a></li>
</ul>
</li>
<li class="nav-item">
<a href="/category/molding">模具制造</a>
<ul class="sub-menu" aria-label="模具制造子分类">
<li><a href="/category/injection">注塑模具</a></li>
<li><a href="/category/stamping">冲压模具</a></li>
</ul>
</li>
<!-- 更多分类 -->
</ul>
</nav>
关键点:
– 使用<nav>标签包裹主导航
– 每个菜单项添加aria-label属性
– 禁止使用JavaScript的hover事件触发子菜单
– 子菜单用CSS的:hover或:focus-within控制显示
在每一页添加结构化面包屑标记,告诉AI搜索引擎该页面在网站中的精确位置:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "首页",
"item": "https://www.gongyexuan.com"
},
{
"@type": "ListItem",
"position": 2,
"name": "精密加工",
"item": "https://www.gongyexuan.com/category/machining"
},
{
"@type": "ListItem",
"position": 3,
"name": "CNC加工",
"item": "https://www.gongyexuan.com/category/cnc"
},
{
"@type": "ListItem",
"position": 4,
"name": "深圳XX精密CNC加工供应商",
"item": "https://www.gongyexuan.com/supplier/12345"
}
]
}
</script>
用Python脚本批量生成面包屑Schema:
def generate_breadcrumb_schema(path_segments, base_url):
"""根据URL路径生成面包屑Schema"""
item_list = []
full_url = base_url
for position, segment in enumerate(path_segments, 1):
full_url += f"/{segment['slug']}"
item_list.append({
"@type": "ListItem",
"position": position,
"name": segment["name"],
"item": full_url
})
return {
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": item_list
}
在XML Sitemap中按内容层级设置优先级,引导AI爬虫优先爬取核心页面:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.gongyexuan.com</loc>
<priority>1.0</priority>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.gongyexuan.com/category/machining</loc>
<priority>0.9</priority>
<changefreq>weekly</changefreq>
</url>
<url>
<loc>https://www.gongyexuan.com/supplier/12345</loc>
<priority>0.7</priority>
<changefreq>monthly</changefreq>
</url>
</urlset>
自动化生成Sitemap的Python脚本:
import xml.etree.ElementTree as ET
def generate_sitemap(urls_with_priority):
"""生成按优先级排序的XML Sitemap"""
urlset = ET.Element("urlset")
urlset.set("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9")
for url_info in sorted(urls_with_priority, key=lambda x: x["priority"], reverse=True):
url_elem = ET.SubElement(urlset, "url")
loc = ET.SubElement(url_elem, "loc")
loc.text = url_info["url"]
priority = ET.SubElement(url_elem, "priority")
priority.text = str(url_info["priority"])
changefreq = ET.SubElement(url_elem, "changefreq")
changefreq.text = url_info.get("changefreq", "monthly")
tree = ET.ElementTree(urlset)
tree.write("sitemap.xml", encoding="UTF-8", xml_declaration=True)
导航优化方案执行6周后的数据:
最显著的变化是,之前需要5次点击才能到达的供应商详情页,现在在AI搜索中被引用的频次提升了10倍以上。
不要为了满足AI爬虫而把导航做得太简单,导致人类用户找不到需要的信息。平衡点是:AI可爬取 + 用户可理解。可以用”分类导航”+”搜索功能”+ “热门推荐”的组合方式满足双方需求。
很多网站的PC端导航和移动端导航不一致,而AI爬虫可能会同时爬取两个版本。确保移动端导航同样使用