Skip to content

Slug

A slug is the human-readable, URL-safe identifier of a resource — lowercase, hyphen-separated, ASCII-only — derived from its title and used to build stable, shareable, SEO-friendly URLs.

Definition

What it is

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.

Why it matters

The slug is the only part of the URL a human reads. It appears in browser bars, in link previews, in search results and in chat previews. A URL like /p/8472/ tells nothing; a URL like /blog/cache-invalidation-strategy/ tells the reader what to expect before opening it. Google has confirmed that URL words carry a small ranking signal; the bigger benefit is the click-through rate, not the algorithm.

Anatomy of a slug

graph LR
  A["¿Cómo crear un jardín?"] -->|lowercase| B["¿cómo crear un jardín?"]
  B -->|strip diacritics| C["¿como crear un jardin?"]
  C -->|fold punctuation to hyphen| D["como-crear-un-jardin"]
  D -->|truncate| E["como-crear-un-jardin"]
  style A fill:#FFF3E0
  style E fill:#E8F5E9

Slug vs title vs id

Aspect

Title

Slug

ID

Audience

Human readers

URLs, search engines

Databases

Accents allowed

Yes

No

N/A

Spaces allowed

Yes

No

N/A

Readable

Yes

Yes, if well done

No

Stable

No, can change

Yes, ideally immutable

Yes

Primary use

Display

URL path

Foreign keys

How to design a good slug

Designing a slug that ages well

  1. Lowercase, always

    URLs are case-sensitive on most servers. Cache and cache are two different pages.

  2. Hyphens, not underscores

    Google recommends hyphens. Underscores are invisible in underlined links.

  3. Drop stop words when the meaning survives

    how-to-write-a-slug reads better than how-to-write-a-slug-for-a-blog-in-2026.

  4. Under 60 characters

    Longer slugs get truncated in search results and link previews.

  5. Immutable unless you redirect

    Changing a slug without a 301 breaks backlinks and search ranking.

Common failures

Origin

In newspaper printing, a slug was a short line of type set above an article, identifying it for the editor and the typesetter. It was not the headline (which was the display copy) and not the story (which was the body); it was the internal label that let everyone in the newsroom refer to the story by one short name. From the print newsroom the word moved to editorial software, where it named the short identifier used in file names and internal references. From editorial software it moved to blogs and CMSs, where it named the short identifier used in URLs.

The slug is the URL-friendly version of the post title. It is usually all lowercase and contains only letters, numbers, and hyphens.

— WordPress Support, *Posts → Slugs*, 2024
1970s · "slug" adopted by editorial software
2003 · WordPress popularises `sanitize_title()`
2008 · Django `slugify()` in django.utils.text
60 · characters recommended max for a slug
301 · redirect that must accompany any change

Evidence

FAQ

How long should a slug be?

Under 60 characters. Longer slugs get truncated in previews and search results.

Can a slug contain numbers?

Yes. 2026-cache-trends is a valid slug.

How do I change a slug without losing SEO?

Add a 301 redirect from the old URL to the new one. Google transfers ranking through 301s over time.

Is a slug the same as an ID?

No. An ID is opaque and machine-generated; a slug is readable and human-generated. Both can identify the same resource.

Connections

Etymology

Origin: metaphor

  • slug (noun): originally a short line of type in newspaper printing, identifying a story

Semantic network

Slugweb-fundamurl-structURLPermalink301 redirecanonicalSEO

● broader ● narrower ● related

Broader

  • web-fundamentals
  • url-structure

Related

Used in the garden

Sources