Use when generating URL slugs from article titles, auditing URL structures for unnecessary depth or length, or reviewing URL patterns in a CMS or router configu
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-length-dc55668bec0c ,按照其中的说明把「length」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
While Google has no strict URL length limit beyond technical constraints, long URLs with deep nesting, excessive parameters, or redundant words are harder for users to read, copy, and share. Google's John Mueller has confirmed that shorter, cleaner URLs are easier to understand and may perform slightly better in search.
the, a, of, in) from slugs — /guide-css-grid is better than /a-guide-to-css-grid/blog/2024/03/category/subcategory/post-title) are harder to share and signal distance from the rootFor each page URL, extract the path component (excluding domain and query string). Flag: (1) Path length over 100 characters. (2) More than 4 path segments (e.g., /a/b/c/d/e has 5 segments). (3) Common stop words in slugs (the, a, an, of, in, at, to, for, with). (4) Dates in URL paths for evergreen content (e.g., /blog/2024/03/css-guide). (5) Session IDs, tracking parameters, or other dynamic values in paths.
/how-to-optimise-your-websites-core-web-vitals → /optimise-core-web-vitals/a-comprehensive-guide-to-css-grid-layout → /css-grid-guide/blog/2024/march/technology/css-grid → /blog/css-gridGoogle recommends keeping URLs 'simple, descriptive, and readable'. Long URLs are more prone to being truncated in search snippets, harder to share, and more confusing to users. Deep URL structures (many subdirectories) do not directly harm rankings, but they can increase crawl distance from the root, reducing crawl frequency for deep pages on large sites.
Parse the pathname of each URL. Count path segments (split by /). Measure character length of the path. Flag slugs containing common stop words. Report the longest 10 URLs by character count and deepest 10 by segment count. Check whether URL generation utilities strip stop words and limit segment depth.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.