A slug is the last segment of a URL, the part a person can read. It is also the only part of the address you choose word by word, which is why it collects opinions. Most of them are about ranking, and most of those are overstated. The rules worth knowing are the ones about what a path can legally hold, what a browser does to the rest, and what happens on the day you change one.
What a Path Can Actually Hold
RFC 3986 splits URI characters into two groups. Unreserved characters are letters, digits, and exactly four punctuation marks: hyphen, period, underscore and tilde. They mean themselves, everywhere, and they never need encoding.
Everything else is either reserved, meaning it has a job somewhere in the URI (/ separates path segments, ? opens the query, # opens the fragment, & and = structure query parameters), or it is outside the allowed set entirely. Reserved characters can appear in a path, but only percent-encoded, and at that point they stop looking like punctuation and start looking like %26.
This is the whole reason a slug generator strips rather than preserves. A title like "Q&A: 50% Off?" contains three characters that each mean something structural in a URL. Keeping them produces a path that either breaks or reads as hex. Spelling them out produces q-and-a-50-percent-off, which survives being pasted anywhere.
What Happens to a Real Title
Each row is a case where the naive answer, deleting anything that is not a letter, gives a worse slug than the considered one.
| Title | Slug | What the rule is doing |
|---|---|---|
| Café Málaga | cafe-malaga | Accents decompose into a base letter plus a mark, and the mark is dropped |
| Straße 12 | strasse-12 | ß has no decomposition at all, so only a lookup table gives the right answer |
| R&D Report 2026 | r-and-d-report-2026 | Deleting the ampersand would leave r-d, which says nothing |
| Google's New API | googles-new-api | The apostrophe closes up rather than splitting a word in two |
| Привет мир | privet-mir | Cyrillic is romanised, since stripping non-Latin letters would leave an empty slug |
| Part 1: Setup | part-1-setup | The colon is reserved, and this is also the classic duplicate-slug collision |
Hyphens, Underscores, and Where the Advice Came From
Both characters are unreserved. Both work. The recommendation for hyphens comes from Google's own documentation on URL structure, which asks for hyphens between words and specifically discourages underscores.
The reason is historical and mechanical: Google's tokeniser treated a hyphen as a word break and an underscore as part of the word, so /blue_widgets was read as one token, bluewidgets, rather than two. Matt Cutts explained this publicly as far back as 2005, and while Google has since said the difference is minor, the recommendation in the documentation has never changed.
The practical case is simpler than the algorithmic one. Hyphens are easier to read, they are what every mainstream CMS produces by default, and they do not disappear under the underline that browsers, chat clients and email apps draw through link text. That last one alone has caused more mis-copied URLs than any ranking effect ever will.
The Rules That Are Worth Following
Short list, because most slug advice is preference dressed up as optimisation. These five have a mechanism behind them.
Lowercase everything
Paths on Linux servers are case-sensitive, so /About and /about are two different URLs. Serving both splits your links between them and creates duplicate content you then have to canonicalise. Lowercase and redirect the variants.
Keep it to a few words
Not because length is a ranking factor, but because URLs get truncated everywhere they are displayed: search results, breadcrumbs, social previews, analytics tables. The first few words are the ones that survive the cut.
Do not put dates in it
A slug like /2024-hosting-guide ages the page even after you update it, and changing the slug to refresh it costs you a redirect. Publication dates belong in structured data, where you can update them freely.
Match the title, not the keyword list
The slug is shown to people in the result. Stuffing it with terms the headline does not contain reads as spam to a human before it reads as anything to a crawler.
Decide it before you publish
This is the only one that is expensive to get wrong. Everything else can be improved in place; changing a live slug is a URL change, with everything that follows from it.
Changing a published slug is a migration, not an edit
The old URL stops existing. Every link pointing at it, every bookmark, every share in a chat thread you cannot edit, and the accumulated ranking signals all point somewhere that now returns 404. A 301 redirect from old to new passes those signals along and is not optional. Google has confirmed 301s pass full PageRank, but redirects still accumulate: chaining three of them across three renames is a real cost, and the cheapest fix is to leave a good-enough slug alone.
Generate a slug from any title
Accents romanised, symbols spelled out, a whole list at a time.
What an Accented URL Looks Like After Encoding
Non-ASCII characters are legal in a modern URL. RFC 3987 defines IRIs, which allow the full Unicode range, and browsers display them as typed. This makes a Cyrillic or Greek slug look perfectly clean in the address bar, which is where the trouble starts.
The moment that URL leaves the browser, it converts to its ASCII form. /статья becomes /%D1%81%D1%82%D0%B0%D1%82%D1%8C%D1%8F. That is what gets pasted into an email, logged in your server access log, shown in analytics, and sometimes what a chat client displays instead of the pretty version. A six-letter word becomes 36 characters of hex.
So the choice is not about correctness. Both forms work. It is about whether the audience for a URL is people who read that script, in which case the native form is friendlier despite the encoding, or a general audience who will mostly see the encoded version. Transliteration gives up the exact spelling to keep the URL legible everywhere it travels.
The Collision Nobody Plans For
Slugs must be unique within a site, and titles are not. "Part 1: Setup" and "Part 1 - Setup" produce the same slug, as do a category page and a post that happen to share a name.
Every CMS resolves this the same way, by appending a counter: part-1-setup-2. WordPress has done it since the beginning, and it is why the internet is full of URLs ending in -2 that nobody chose.
The counter is a fallback, not a fix. A slug ending in -2 tells a reader nothing and looks like a mistake, which it usually is: two posts that slug identically are often two posts that should have had more distinct titles in the first place. Converting a batch of titles at once is useful precisely because the collisions show up before anything is published, while the titles are still cheap to change.
Frequently Asked Questions
Related Tools
Keep Reading
camelCase, snake_case, kebab-case: Which Case Goes Where
The convention each language expects, the one language where capitalisation changes behaviour, and why acronyms break every rule.
URL Encoding: encodeURI vs encodeURIComponent, and the Plus Sign
The two JavaScript functions are not interchangeable, and picking the wrong one is the most common URL bug there is. Plus where %2520 comes from.
Title and Meta Description Length: Pixels, Not Characters
Google truncates by rendered width, so a title of capitals runs out thirty characters early. Plus why it rewrites most descriptions anyway.
Word Count Targets: What Editors, Platforms and Google Expect
Two counters can disagree by five percent on the same paragraph. Here is how counting actually works, and the targets worth writing to.