URL slugs: length, hyphens, case and special characters
A URL slug is the readable last part of a URL path. Short, lowercase, hyphen-separated words work best. What Google recommends and the checks.
A URL slug is the readable last part of a URL’s path, such as merino-crew-socks in https://example.com/products/merino-crew-socks, usually built from the page title.
Google’s URL structure guidance recommends readable words over long ID numbers, and hyphens over underscores to separate words, because hyphens clearly mark a word boundary. It also notes that URLs are case-sensitive: /APPLE and /apple are different URLs. Characters outside the URL-safe set have to be percent-encoded, so a space becomes %20.
Category: URL Structure
Why it matters
A slug is part of what a searcher sees in the result and what a person reads in a shared link. /products/merino-crew-socks says what the page is; /p/48213 does not. The bigger risks come from inconsistency. Mixed case or a mix of hyphens and underscores creates near-duplicate URLs for one page, and spaces and special characters turn into percent-encoded strings that are hard to read and easy to break. Renaming a live URL has a cost too. It needs a permanent redirect, and the change usually brings a period of ranking movement, so the convention matters most for new pages.
How squirrelscan checks it
Most URL rules look at one path and report at info or warning level. url/slug-keywords warns when the last segment is a numeric ID, a hash or a generic pattern such as post-123, except pagination such as /page/2. url/hyphens warns on underscores in the path, url/lowercase on uppercase letters, and url/special-chars on spaces, symbols such as & or #, non-ASCII characters and double slashes. url/stop-words notes paths with more than two English stop words, and url/length notes URLs over 75 characters, warns over 100 and flags more than four path segments. url/slug-convention is site-wide. It learns the site’s own separator, case and trailing slash, plus date use and depth per page type, and reports the pages that break a convention 70% of comparable pages follow.
Only url/length looks at the query string, as part of the full URL.
| Rule | What it flags | Severity |
|---|---|---|
| Non-descriptive URL slug: numeric IDs and generic patterns | A slug like /p/48213 tells a reader and a crawler nothing. squirrel classifies the last path segment and flags the ID-shaped ones. | info |
| Mixed URL conventions: finding the minority form | Half your paths ending in a slash and half not is how canonical bugs start. squirrel computes your site’s own norm and reports what deviates. | warning |
| Stop words in a URL slug: when to drop them | the, of and for add characters without adding meaning to a slug. squirrel counts them in each path and only reports the pile-ups. | info |
| Underscores in URLs: why hyphens separate words | Google reads blue-shoes as two words and blue_shoes as one. squirrel flags every crawled path containing an underscore. | warning |
| Special characters in a URL path: what breaks and why | Spaces, percent signs and non-ASCII characters in a path break when copied and pasted. squirrel decodes the path and reports what it finds. | warning |
| Uppercase in a URL: the duplicate content it creates | Most servers treat /Page and /page as two URLs serving the same content. squirrel flags every crawled path containing a capital letter. | warning |
| URL length: when a URL is long enough to be a problem | Long URLs get truncated in results and shares, and usually signal deep nesting. squirrel measures the full URL and counts path segments. | info |
How to fix it
Generate the slug once, from the title, when the page is created:
https://example.com/products/merino-crew-socks
https://example.com/products/merino-crew-socks-48213
The second form keeps an ID for routing and still reads correctly (the slug fix). Transliterate to ASCII, lowercase, replace everything else with a hyphen and collapse repeats (the special character fix). For existing URLs, change the slug at the source and 301-redirect the old path, or leave it until you restructure anyway (the hyphen fix, the length fix). A site written in a non-Latin script has good reason to keep its characters, and can disable the special character rule.
Run the check
squirrel audit https://example.com --rule-include url/slug-keywords,url/slug-convention,url/stop-words,url/hyphens,url/special-chars,url/lowercase,url/lengthA signed-out local audit costs nothing.
Related terms
- Trailing slash: Whether URLs end in /; /page and /page/ are different URLs, so a site should pick one and redirect the other.
- URL parameters: Key-value pairs after ? in a URL; tracking and sort parameters can multiply URLs for the same content.