On-page

URL slugs: what they are and how to write them well

6 min readUpdated

A URL slug is the part of a web address that names one specific page, usually the last segment: in https://example.com/guides/atlas-40/, the slug is atlas-40. Google recommends using "readable words rather than long ID numbers" in URLs, separated by hyphens. The slug is one of the on-page signals a reader sees before opening the page.

What a slug is

A slug is the human-readable name of a page inside its address. The rest of the address says where the page lives, the domain and the folders above it; the slug says which page it is.

The word comes from publishing, where a slug was a short working name for a story. On the web it is the same idea: a short, stable label, usually generated from the page title when the page is created, and then kept.

Two addresses can point to the same content on the same site and yet look very different:

https://example.com/guides/atlas-40-travel-backpack/
https://example.com/index.php?id=4817&cat=3

Both work. Only the first tells a reader, and anyone the link is shared with, what to expect. The difference matters most where the address is all a person sees: in a pasted link in a chat, in a printed document, or in a list of results where the address is shown above the title. A slug made of words carries meaning into all of those places; an ID number carries none.

What Google recommends

Google's guide to URL structure, last updated on and checked on , gives three recommendations that apply directly to slugs.

  • Use words

    "When possible, use readable words rather than long ID numbers in your URLs."

  • Use your audience's language

    "Use words in your audience's language in the URL (and, if applicable, transliterated words)."

  • Separate words with hyphens

    Google recommends "using hyphens (-) instead of underscores (_) to separate words in your URLs, as it helps users and search engines better identify concepts in the URL." It explains that underscores are commonly used to join words that belong together, as in programming names such as format_date.

The same guide frames all of this as making URLs "intelligible to humans." A slug that a person can read aloud and understand passes that test.

Writing a good slug

  • Name the page, not the site

    The domain already says whose site it is. The slug should say what this page is about.

  • Keep the meaningful words

    Short connecting words often add length without meaning; dropping them usually makes a slug clearer. Keep any word that changes the meaning.

  • Use lowercase

    Web servers can treat upper and lower case as different addresses, so a consistent lowercase slug avoids two versions of one page.

  • Leave dates and numbers out unless they define the page

    A slug that contains a year ages with it. A model number that is the product's name belongs; an internal ID does not.

  • Do not repeat the folder

    In /guides/backpack-guide/, the second "guide" adds nothing.

Google publishes no ideal length for a slug, and neither does this page. A slug that names the page in a few words is long enough.

Slugs a CMS writes for you

Most systems generate the slug from the title when a page is first saved, and that is a reasonable start. Check it before publishing, because the generated version keeps everything the title had: punctuation turned into extra hyphens, words that only made sense in the headline, sometimes a number added to avoid a clash with an older page. Editing the slug before the page goes live costs nothing; editing it afterwards means a redirect.

Slugs and URL parameters

A slug names a page; parameters after a question mark describe a view of it, such as a sort order or a filter. They do different jobs and are best kept apart. Google's URL guide asks for the common encoding when parameters are used: "an equal sign (=) to separate key-value pairs" and an ampersand to add further ones, as in ?category=dresses&sort=low-to-high. Pages that exist only as parameter combinations of another page usually belong under one canonical address, as covered under the canonical tag.

Changing a slug that is already live

Changing a slug changes the page's address, and every link to the old address breaks unless it is redirected. Before changing one, decide whether the improvement is worth the move. A slightly imperfect slug that has been linked for years is usually better left alone.

If you do change it, redirect the old address to the new one with a permanent redirect, as covered under 301 redirects, and update internal links to point at the new address directly. Check that the page's canonical tag names the new address too.

Some systems help. WordPress, for example, redirects old addresses of posts to their new slugs automatically, but not those of pages; the details are under WordPress redirects.

Slugs on other languages and scripts

Google's recommendation to use the audience's language extends to scripts other than Latin. A slug can be written in the page's own language, or transliterated into Latin letters, and browsers display it readably either way. What matters is that it reads naturally to the people the page is for.

FAQ

What is a slug in a URL?

The slug is the part of the address that names one specific page, usually the last segment: in example.com/guides/atlas-40/, it is atlas-40. It is typically generated from the page title when the page is created. Google recommends readable words separated by hyphens rather than ID numbers.

Should I change a URL slug to improve it?

Only if the gain is clear. Changing a slug changes the address, so links to the old one break unless you add a permanent redirect and update your internal links. A slug that is slightly imperfect but already linked from many places is usually better left as it is.

Should I use hyphens or underscores in a slug?

Hyphens. Google recommends hyphens instead of underscores to separate words, because hyphens help users and search engines identify the separate concepts in a URL, while underscores are commonly used to join words that belong together, such as names in programming code.

How long should a URL slug be?

Google does not publish an ideal length, and there is no reliable figure to quote. A good slug names the page in a few meaningful words and leaves out filler, dates and IDs that do not define the page. If it reads clearly aloud, it is long enough.