URL slugs: turning a title into a clean address
The slug is the readable part at the end of a page address, such as creme-brulee-10-easy-tips. A good slug is short, lowercase, uses hyphens, and still makes sense when someone reads it in a link. Here is the step-by-step recipe and the edge cases that trip people up.
Make a slug from a title
The recipe, step by step
- Replace letters that do not decompose. ß becomes ss, æ becomes ae, ø becomes o, œ becomes oe.
- Strip accents. Unicode normalisation (NFKD) splits é into e plus a separate accent mark; drop the mark and keep the e.
- Handle symbols with meaning. Turn
&into “and” and remove apostrophes so “isn’t” becomesisnt, notisn-t. - Lowercase everything. Many servers treat
/Guideand/guideas different pages. - Replace every run of other characters with one hyphen, then trim hyphens from both ends.
- Shorten if needed, cutting at a hyphen so no word is chopped in half.
Worked examples (output of the tool above):
| Title | Slug |
|---|---|
| Crème Brûlée: 10 Easy Tips! | creme-brulee-10-easy-tips |
| Rock & Roll Isn’t Dead | rock-and-roll-isnt-dead |
| Straße in Malmö — Øresund | strasse-in-malmo-oresund |
| How to Pick the Right Color for a Small Room in Winter | how-pick-right-color-small-room-winter (small words dropped) |
Hyphens, not underscores
Search engines have long recommended hyphens as word separators in URLs, because an underscore can be read as joining two words into one. Hyphens are also easier to see when a link is underlined. Use underscores only when a system requires them, for example some file-naming conventions or identifiers in code.
How long should a slug be?
There is no hard rule, but shorter is easier to read, share and type. Three to six meaningful words usually cover the topic. Dropping small words such as “the” and “of” helps, but keep them when removing them changes the meaning: the title “To Be or Not to Be” shrinks to be-not-be without its small words, so untick the option for titles like that.
Edge cases
- Titles in non-Latin scripts. A Japanese or Russian title has no Latin letters to keep, so a basic slugifier returns almost nothing. Either transliterate (write the sounds in Latin letters), write a short English slug by hand, or keep the original script and let the browser percent-encode it, as explained in the URL encoding guide.
- Symbols that carry meaning. “C++ vs C#” becomes
c-vs-c, which loses the point. Writecpp-vs-csharpby hand. - Numbers and dates. Avoid putting a year in a slug for content you plan to refresh; the URL then looks stale even after an update.
- Duplicates. Two posts with the same title need different slugs. Content systems usually append
-2; a more descriptive word is friendlier.
Changing a slug after publishing
A slug is part of the address, so changing it breaks every existing link and bookmark. If you must change it:
- Publish the page at the new slug.
- Add a permanent redirect (HTTP 301 or 308) from the old address to the new one.
- Update internal links and the sitemap to point straight at the new address.
- Keep the redirect in place indefinitely.
Questions
Should the slug match the page title exactly?
No. The title can be long and expressive; the slug only needs the core words. “Ten Easy Tips for a Perfect Crème Brûlée at Home” can live at creme-brulee-tips.
Are capital letters ever fine?
They work, but mixed case invites duplicate addresses and typos. Lowercase is the safe convention.
Does the tool send my titles anywhere?
No. It runs in your browser and stores nothing.