跳到正文
Skillpedia
SEO75k · #2880

hyphens

它能做什么

这项技能检查网站的网址,并建议使用连字符代替下划线或空格。适用于希望网址在搜索中更清晰的网站所有者。

适用场景

  • ✓当你的页面地址使用下划线分隔单词的时候。
  • ✓当你规划新的网址结构或 slug 格式的时候。
  • ✓当你把下划线网址的页面迁移为连字符网址的时候。

技能链接

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

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/hyphens/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请检查我的页面地址,并把下划线改为连字符。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会扫描网址路径中的下划线、编码空格和混合分隔符。它会建议连字符版本,以及保持现有链接可用所需的 301 重定向。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Use hyphens in URLs

Google's search systems interpret hyphens in URLs as word boundaries, enabling it to match the URL against individual keyword queries. Underscores join words into a single token, meaning /seo_practices is seen as one word 'seopractices' rather than two separate words 'seo' and 'practices'.

Quick Reference

  • Use hyphens (-) to separate words in URLs — Google treats hyphens as word separators, underscores as part of the word
  • /best-seo-practices is better than /best_seo_practices or /bestseopractices
  • Changing existing URLs from underscores to hyphens requires 301 redirects to preserve link equity

Check

Inspect the URL path segment of each page. Flag any URL that contains: (1) Underscores (_) as word separators (e.g., /best_practices). (2) Spaces encoded as %20 or + in path segments. (3) Mixed separators in the same URL (e.g., /best-practices_guide). Report the count of non-hyphenated URLs by category.

Fix

  1. Identify all pages with underscores or spaces in URL path segments.
  2. Generate the hyphenated equivalent: replace _ with -, spaces/%20 with -.
  3. Set up 301 permanent redirects from the old URLs to the new hyphenated URLs.
  4. Update internal links throughout the site to point to the new URLs.
  5. Submit the new URLs to Google Search Console for re-indexing.
  6. Update your sitemap.xml to include only the new hyphenated URLs.
  7. In your CMS or slug-generation function, enforce hyphens going forward:
    • Slug: title.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '')

Explain

Google's John Mueller has confirmed that Google interprets hyphens as word separators in URLs, but treats underscores as word joiners. This means a URL with underscores matches fewer individual keyword queries. For example, /web_design would match 'web_design' as a single token, while /web-design matches both 'web design' and 'webdesign' queries.

Code Review

Parse all URL paths used in the application's router or CMS slug fields. Flag any path segment containing _ characters between words or any %20 space encoding. Verify slug-generation utilities produce lowercase hyphenated output. Check redirect rules to confirm old underscore URLs are permanently (301) redirected to their hyphenated equivalents.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/seo/hyphens

常见问题

为什么连字符比下划线更好?

这项技能指出,Google 会把连字符识别为单词边界,而下划线会把单词连在一起成为一个整体。

修改后旧网址怎么办?

这项技能建议从旧地址做 301 重定向,并更新内部链接和站点地图。

新网址需要提交吗?

这项技能建议将新网址提交到 Google Search Console 以重新索引。

详情

作者的原始描述

Use when auditing URL structures for word separator format, generating slugs from titles, or planning a URL migration from underscores or spaces to hyphens with appropriate redirects.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2880
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能