Skip to content

What it is

A slug is the human-readable, URL-safe identifier of a resource, derived from its title and used to build stable, shareable URLs.

A slug is the part of a URL that names the resource in plain words. In https://example.com/blog/how-to-write-a-slug/, the slug is how-to-write-a-slug. It is lowercase, hyphen-separated, ASCII-only and free of spaces, accents and punctuation. It is not an ID (IDs are opaque, slugs are readable) and it is not the title (titles keep spaces and accents; slugs do not).

In content management systems, the slug is often generated automatically from the title by a slugifier — a function that lowercases, strips diacritics, replaces whitespace and punctuation with hyphens, and truncates to a safe length. WordPress calls it sanitize_title; Django calls it slugify; Rails calls it parameterize.