trailing-slash
它能做什么
这项技能检查网站是否统一使用一种网址风格,即是否带结尾斜杠。适用于希望避免搜索结果中出现重复页面的网站所有者和开发者。
适用场景
- ✓当网站对带结尾斜杠和不带结尾斜杠的网址都提供同一页面的时候。
- ✓当内部链接、站点地图条目和 canonical 标签使用不同的网址风格的时候。
- ✓当网站迁移到新平台,网址规则可能已改变的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/trailing-slash/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“Google 把我的一些页面显示了两次,一次带结尾斜杠,一次不带。请帮我修复这些网址。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会测试两种网址版本,并检查内部链接和站点地图。然后它会推荐一种首选风格,并从另一种版本做永久重定向。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use trailing slashes consistently
Inconsistent trailing slashes create duplicate content — Google sees /page and /page/ as two separate URLs competing for the same ranking, splitting PageRank between them.
Quick Reference
- Pick one convention — trailing slash or no trailing slash — and enforce it site-wide with 301 redirects
- Both
/page/and/pagemust not return HTTP 200; one must redirect to the other - Set
rel="canonical"to the preferred version on all pages - Ensure all internal links, sitemaps, and canonical tags use the same convention
Check
For a sample of URLs, test both the trailing-slash and non-trailing-slash versions. Both should NOT return HTTP 200 — one must 301-redirect to the other. Check that internal links, sitemap <loc> values, and canonical tags all use the same convention consistently.
Fix
Choose a canonical URL convention. Add server or framework redirect rules so the non-preferred variant permanently redirects (301) to the preferred one. Update all internal links, canonical tags, and sitemap entries to use the preferred format.
Explain
Explain why /page and /page/ are treated as distinct URLs by default, how this creates duplicate content, and how 301 redirects and canonical tags resolve the ambiguity.
Code Review
Review metadata generation, rendered HTML, structured data, and response headers related to Use trailing slashes consistently. Flag exact routes or templates where search-facing output violates the rule, and describe how to verify the final page output.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/seo/trailing-slash
常见问题
为什么这两个网址会被视为不同?
默认情况下,搜索引擎会把 /page 和 /page/ 当作两个不同的地址,从而分散排名信号。
如何解决重复问题?
这项技能推荐从非首选版本做 301 重定向,并在页面上使用 canonical 标签。
站点地图也要更新吗?
需要。这项技能指出,站点地图条目应使用与首选网址相同的格式。
详情
作者的原始描述
Use when applies to all static and dynamic websites. Use when auditing a site for duplicate content, setting up a new site, or after migrating platforms that changed URL conventions.
热度
- GitHub 星标
- 75k
- 排名
- #3061
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。