What a slug is
The slug is the human-readable tail of your URL - the part after the domain that names this specific page. In /blog/what-is-json/, the slug is what-is-json. It is the one part of a URL you control entirely, and it does three jobs at once: identifies the page to users, hints at the topic to search engines, and stays clean enough to copy, paste, and remember.
The formatting rules that matter
- Lowercase everything. URLs can be case-sensitive; lowercase removes a whole class of 404s and duplicated links.
- Hyphens between words. Hyphens separate words for both readers and crawlers. Underscores do not, so they are the classic slug mistake.
- No stop words when they add nothing. 'a', 'an', 'the' bloat the URL without carrying meaning, though feel free to keep them when the phrase reads better.
- Strict characters only. Letters, digits, and hyphens. Drop accents, punctuation, emoji, and spaces.
- Absolute stability. Once published, never change a slug. Old 404s rip bookmark collections and backlinks out from under you; when you must change one, redirect the old path.
How descriptive should a slug be?
Enough that someone seeing only the URL guesses the topic, and short enough to type without pain. /blog/how-to-verify-sha256-hash/ survives the test; /blog/p/48290 and a thirty-word summary fail it. When a tool-generated title contains artifacts like double spaces or stray symbols, clean them before generating the slug, not after.
Slug and title: keep them in sync
Your slug should derive from your final title, not a rough draft. If you retitle a page after publishing, the slug now disagrees with the visible heading, and one of them is lying to readers and crawlers. Generate the slug as the last step, from the final title, and treat both as frozen afterwards.
Auto-generating slugs without pain
Slug generators remove the discipline problem: paste any title, and the correct lowercase-hyphenated form appears immediately. Use one as your starting point, then manually shorten or disambiguate for truly short, clean links. Wherever slugs are created - blog systems, CMS editors, product pages - route them through the same normalization so they all follow the same style.