elefcode
← All guides

Web & APIs · 4 min read

URL Slugs and SEO-Friendly URLs

The slug is the human-readable part of a URL — the how-to-make-bread in example.com/how-to-make-bread. It is a small detail that affects how your page reads in search results, how shareable the link feels, and how well people can guess what a page contains.

This guide covers what makes a slug good and the conventions worth following.

Try it yourself with the related tool.

Generate a slug →

Advertisement

What a good slug looks like

Lowercase, hyphen-separated, short, and descriptive. Strip accents and punctuation so the URL is safe everywhere, drop filler words that add no meaning, and keep the main keyword near the front. css-grid-guide beats the-complete-and-ultimate-guide-to-using-css-grid-in-2026.

Hyphens, not underscores

Search engines treat hyphens as word separators but underscores as joiners — so blue-widget reads as two words while blue_widget can be read as one. This is a long-standing, well-documented distinction, and it is why essentially every CMS generates hyphenated slugs.

Changing a slug later

Changing a published URL breaks every existing link and loses the ranking that URL has built. If you must change it, set up a 301 redirect from the old slug to the new one so links and search equity carry over. Better still, choose a slug that will not need to change — avoid embedding years or "new" in it.

Beyond the slug

Keep URL structure shallow and logical; deeply nested paths are harder to read and share. Use a canonical tag so that variations of a URL (with tracking parameters, for example) consolidate to one version, and keep campaign parameters off internal links.

Related guides