hyphens
它能做什么
这项技能检查网站的网址,并建议使用连字符代替下划线或空格。适用于希望网址在搜索中更清晰的网站所有者。
适用场景
- ✓当你的页面地址使用下划线分隔单词的时候。
- ✓当你规划新的网址结构或 slug 格式的时候。
- ✓当你把下划线网址的页面迁移为连字符网址的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/hyphens/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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-practicesis better than/best_seo_practicesor/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
- Identify all pages with underscores or spaces in URL path segments.
- Generate the hyphenated equivalent: replace
_with-, spaces/%20with-. - Set up 301 permanent redirects from the old URLs to the new hyphenated URLs.
- Update internal links throughout the site to point to the new URLs.
- Submit the new URLs to Google Search Console for re-indexing.
- Update your sitemap.xml to include only the new hyphenated URLs.
- 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.
常见问题
为什么连字符比下划线更好?
这项技能指出,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.
热度
- GitHub 星标
- 75k
- 排名
- #2880
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。