invalid-links
它能做什么
这项技能检查页面链接中是否有爬虫无法跟随的空目标、仅由 JavaScript 实现或非网址目标。适用于构建导航和动态链接的开发者。
适用场景
- ✓当一个外观像链接的按钮把 javascript:void 作为目标的时候。
- ✓当动态菜单项没有真实网址的时候。
- ✓当审计报告某些链接的目标为空或仅为锚点的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/invalid-links/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我的页面中是否有搜索引擎无法跟随的链接。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会读取每个链接元素,并标记空的、仅锚点的、基于 JavaScript 的或缺失的 href。它会建议用真实网址替换它们,并且仅使用 JavaScript 来增强导航。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Fix invalid links
Google can only follow links declared as valid <a href> elements with crawlable URL values. Invalid links — empty hrefs, JavaScript voids, or non-URL content — prevent PageRank from flowing to linked pages and stop Googlebot from discovering those destinations.
Quick Reference
- Invalid
<a>tags (empty href, JavaScript voids, non-URL values) are not crawlable — Googlebot cannot follow them - Links must use crawlable
<a href='...'>elements with valid absolute or relative URLs to pass PageRank and be followed - JavaScript-only navigation (onClick handlers without
href) is invisible to search engine crawlers
Check
Parse all <a> elements on the page. Flag links where href: (1) is empty (href='' or href='#' with no meaningful target). (2) starts with javascript: (e.g., href='javascript:void(0)'). (3) starts with mailto: or tel: — these are valid but not crawlable for page discovery. (4) contains only a fragment identifier that references an anchor not present on the page. (5) is absent entirely (<a> without any href attribute). Report the count per type.
Fix
- For links using
href='javascript:void(0)'orhref='#'as navigation triggers:- Add a real URL as the href value
- Use JavaScript to enhance the navigation, not replace it
- Before:
<a href="javascript:void(0)" onclick="openModal()">View Details</a> - After:
<a href="/products/details" onclick="openModal(event)">View Details</a>
- For
<a>elements without href (used as button-like elements):- If they trigger navigation: add href
- If they trigger actions only: change to
<button>elements
- For empty
href='': either add the correct URL or remove the<a>wrapper - For
href='#'anchors: use meaningful fragment IDs that reference actual page sections (href='#features'whereid='features'exists)
Explain
Google's documentation states that crawlable links must be <a> tags with an href attribute containing a valid URL. Links with javascript: hrefs, empty hrefs, or no href attribute are not followed by crawlers. This means pages only reachable through invalid links are not discovered by Googlebot, and any intended PageRank flow is blocked.
Code Review
Query all <a> elements in the rendered DOM. For each, extract the href attribute. Flag: absent href, empty string, '#' only, values starting with javascript:, values starting with void. Separately flag <div>, <span>, or <button> elements with onclick navigation handlers that lack a corresponding <a href> — these are not crawlable.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/seo/invalid-links
常见问题
无效的 href 为什么影响 SEO?
这项技能指出,爬虫无法跟随无效链接,因此目标页面可能永远不会被发现。
仅靠 JavaScript 的导航能工作吗?
这项技能指出,没有 href 的 onclick 导航对搜索引擎爬虫是不可见的。
mailto 和 tel 链接有问题吗?
这项技能指出它们是有效的,不过对页面发现并无帮助。
详情
作者的原始描述
Use when auditing a page's link elements for crawlability, reviewing JavaScript-heavy SPAs where navigation may not use `<a href>` tags, or checking that dynamically generated links have valid href values.
热度
- GitHub 星标
- 75k
- 排名
- #2899
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。