The slug is the human-readable part of a URL that identifies a page — the article-title bit at the end. It is a small detail with real impact on usability and search visibility. Designing slugs well makes URLs that people trust and click, and that search engines understand. This guide covers the principles.
What a slug is
In a URL like /blog/how-to-format-json, the slug is how-to-format-json. Instead of an opaque numeric ID, it describes the content in words. A reader can tell what the page is about before clicking, and the descriptive words give search engines useful context about the page.
What makes a good slug
- Readable — words a human understands, not random characters or IDs.
- Lowercase — to avoid case-sensitivity confusion across servers.
- Hyphen-separated — search engines treat hyphens as word separators; underscores they do not.
- Concise — include the key words, drop filler like "the" and "a".
- Stable — once published and linked, a slug should not change.
Hyphens, not underscores
This trips people up: for word separation in URLs, use hyphens. Search engines interpret my-great-article as three words but my_great_article as one. Spaces are not allowed at all and get percent-encoded into ugly %20 sequences. Hyphens keep the URL clean and the words distinct.
Generating slugs reliably
To turn a title into a slug, lowercase it, replace spaces with hyphens, strip punctuation, and transliterate accented characters to their plain forms so that "Café" becomes "cafe". Collapse repeated hyphens and trim them from the ends. Doing this consistently produces clean, predictable URLs from any title.
A note on changing slugs
Because others link to your URLs and search engines index them, changing a slug breaks those links and discards accumulated ranking. If you must change one, set up a 301 redirect from the old slug to the new so nothing is lost. The best policy is to choose a good slug once and keep it.