Home / Developer / Slugify

Slugify

Slugify converts a title into a URL-safe slug by lowercasing, stripping accents, and replacing runs of non-alphanumeric characters with single hyphens.
Slug
como-creer-un-titulo-valido

A slug is the human-readable part of a URL made from a title. This strips accents, lowercases, and replaces anything that is not a letter or number with a hyphen, producing a clean, link-safe string.

How it works

The text is Unicode-normalised so accented letters lose their marks, lowercased, then every run of non-alphanumeric characters becomes a single hyphen, with leading and trailing hyphens trimmed.

Questions

Why remove accents?

Accented and non-Latin characters get percent-encoded in URLs, which is ugly and harder to read, so slugs are usually reduced to plain ASCII.

Does slug length matter for SEO?

Shorter, descriptive slugs are generally preferred; extremely long slugs add little and are harder to share.