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 dynami
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-invalid-links-c5ad6b840a22 ,按照其中的说明把「invalid-links」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
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.
<a> tags (empty href, JavaScript voids, non-URL values) are not crawlable — Googlebot cannot follow them<a href='...'> elements with valid absolute or relative URLs to pass PageRank and be followedhref) is invisible to search engine crawlersParse 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.
href='javascript:void(0)' or href='#' as navigation triggers:
<a href="javascript:void(0)" onclick="openModal()">View Details</a><a href="/products/details" onclick="openModal(event)">View Details</a><a> elements without href (used as button-like elements):
<button> elementshref='': either add the correct URL or remove the <a> wrapperhref='#' anchors: use meaningful fragment IDs that reference actual page sections (href='#features' where id='features' exists)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.
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/en/rules/seo/invalid-links