Slugify string

What is a Slugify String?

A slug is the URL-friendly part of an address that identifies a page, such as how-to-bake-sourdough in example.com/blog/how-to-bake-sourdough. Good slugs are short, readable, lowercase and contain only letters, digits and hyphens. This tool converts any title or string into a clean slug, which also works for file names and HTML IDs.

How to use it

  1. Paste the title or text.
  2. Copy the generated slug.

Examples

  • 10 Tips for Better Sleep! becomes 10-tips-for-better-sleep
  • Crème Brûlée & Café au Lait becomes creme-brulee-and-cafe-au-lait (depending on how & is handled)
  • What's new in Vue 3.4? 🚀 becomes whats-new-in-vue-3-4

What slugify does

  • Transliterates accented letters to ASCII: é to e, ü to u.
  • Lowercases everything.
  • Replaces spaces and punctuation with hyphens.
  • Removes emoji and other symbols.
  • Collapses repeated hyphens and trims them from the ends.

SEO best practices for slugs

  • Keep slugs short and descriptive; 3 to 6 words is plenty.
  • Use hyphens, not underscores. Google treats hyphens as word separators.
  • Leave out dates and numbers that will become outdated, such as a year in an evergreen article.
  • Stop words like a, the and of can often be removed.
  • Do not change slugs of published pages without a 301 redirect, or you lose rankings and create 404 errors.

In code

Libraries such as @sindresorhus/slugify (JavaScript), python-slugify and Django's slugify do the same; make sure duplicates get a suffix like -2.

Frequently Asked Questions

What is a URL slug?

The readable part of a URL that identifies a specific page, usually made from the page title.

Should I use hyphens or underscores in URLs?

Hyphens. Search engines treat hyphens as word separators but may join words separated by underscores.

Can I change the slug of a published page?

Yes, but add a 301 redirect from the old URL to the new one so you keep traffic and rankings.

What happens to accented characters?

They are converted to plain ASCII letters, so é becomes e and ñ becomes n.