Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)75k · #2899

invalid-links

Skill này làm gì

Skill này kiểm tra liên kết trên trang xem có đích rỗng, chỉ dùng JavaScript hoặc không phải URL mà trình thu thập không theo được không. Skill dành cho lập trình viên xây điều hướng và liên kết động.

Khi nào nên dùng

  • ✓Khi một nút được định dạng như liên kết dùng javascript:void làm đích.
  • ✓Khi các mục menu động không có URL thật.
  • ✓Khi kết quả kiểm tra báo liên kết có đích rỗng hoặc chỉ là hash.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/invalid-links/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/invalid-links/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể kiểm tra trang của tôi xem có liên kết nào mà công cụ tìm kiếm không theo được không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent đọc mọi phần tử liên kết và đánh dấu các href rỗng, chỉ có hash, dựa trên JavaScript hoặc bị thiếu. Agent gợi ý thay bằng URL thật và chỉ dùng JavaScript để nâng cấp điều hướng.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

  1. For links using href='javascript:void(0)' or href='#' 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>
  2. 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
  3. For empty href='': either add the correct URL or remove the <a> wrapper
  4. For href='#' anchors: use meaningful fragment IDs that reference actual page sections (href='#features' where id='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

Câu hỏi thường gặp

Vì sao href hỏng ảnh hưởng SEO?

Skill nói trình thu thập không thể theo liên kết không hợp lệ, nên các trang đích có thể không bao giờ được khám phá.

Điều hướng chỉ dùng JavaScript có hoạt động không?

Skill nói điều hướng onclick không có href là không nhìn thấy đối với trình thu thập của công cụ tìm kiếm.

Liên kết mailto và tel có vấn đề không?

Skill nói chúng hợp lệ, dù không giúp ích cho việc khám phá trang.

Chi tiết

Mô tả gốc của tác giả

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.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#2899
Giấy phép
MIT
Cập nhật
31/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự