· 6 min read
A slug is the human-readable part of a URL that identifies a page: the last segment, usually lowercase words joined by hyphens. It is the one piece of a URL that is written for people rather than for machines.
| Convention | Why |
|---|---|
| Lowercase | Some servers treat URLs as case sensitive, so mixed case creates two addresses |
| Hyphens, not underscores | Underscores can be hidden by the underline in a link |
| No spaces | They encode as %20 and make the URL unreadable |
| Accents transliterated | Accented URLs work but are displayed encoded in many places |
| Short | A truncated URL in search results and chat previews should still make sense |
Punctuation goes. Leading and trailing hyphens go. Repeated hyphens collapse to one. Words like a, the and of are often dropped, though this matters less than people claim and can make a title harder to recognise.
Numbers are worth keeping when they carry meaning, such as a version or a year. They are worth avoiding when they encode a position that might change, because a slug ending in part-3 is a promise about ordering.
A URL can contain them, and browsers display them correctly. The problem is everything else: older systems, analytics tools and some chat clients show the percent-encoded form instead, which is unreadable. Transliteration is usually the more practical choice, with the real title in the page rather than in the address.
Every existing link points at the old one. Changing it without a redirect turns all of them into errors, loses whatever ranking the page had accumulated, and breaks bookmarks silently. With a permanent redirect most of that is preserved, but the redirect then has to be maintained indefinitely.
Decide the slug when the page is created, not when it is published, and do not derive it automatically from a headline you are still editing. A slug following a changing title is how a page ends up with four redirects pointing at it.
The mechanical part is transliterate, lowercase, replace anything that is not a letter or number with a hyphen, collapse repeats, and trim the ends. The slug generator here does that in the browser, so a draft title that is not public yet stays on your machine.
Hyphens. An underscore can be hidden by the underline styling on a link, which makes the URL ambiguous when read aloud or in print.
Only if the date identifies the thing. A date in the URL makes an article look stale to a reader even after you update it.
Yes, but add a permanent redirect from the old one and keep it. Without it, every existing link, bookmark and search result points at an error.