A URL slug is the human-readable identifier in a URL — the part that comes after the domain and before any query strings. /blog/how-to-cook-pasta/ contains a slug. /products/red-wireless-headphones/ contains a slug.

Good slugs help SEO, look better in shares, and give clues about page content. Bad slugs hurt all three. Here's how to generate good slugs from any title.

What makes a slug "good"

A good slug is:

  • Readable — a human can guess the content from the URL alone
  • Short — typically 3-6 words, 30-60 characters
  • Lowercase — URLs are conventionally lowercase
  • Hyphen-separated — underscores work but hyphens are the convention
  • ASCII-only — diacritics and special characters are stripped
  • Stable — once chosen, the slug doesn't change (changing it breaks links)
  • Keyword-rich — contains the search terms users would search for
  • Free of stop words when possible — strip a, the, and, or when they don't add meaning

The conversion algorithm

Here's a robust slug-generation algorithm in JavaScript:

function slug(text) {
  return text
    .toLowerCase()
    // Strip diacritics (é → e, ñ → n)
    .normalize('NFD')
    .replace(/[\u0300-\u036f]/g, '')
    // Replace non-alphanumeric with hyphen
    .replace(/[^a-z0-9]+/g, '-')
    // Remove leading/trailing hyphens
    .replace(/^-+|-+$/g, '');
}

slug('Hello, World!');           // → 'hello-world'
slug('Café résumé naïve');       // → 'cafe-resume-naive'
slug('  10 Best Tips for 2026'); // → '10-best-tips-for-2026'

This is the algorithm our slug converter uses. It handles diacritics, multi-character separators, punctuation, and emoji (which get stripped).

Should you strip stop words?

Stop words are common words that carry little meaning: a, an, the, and, or, but, in, on, at, to, for, of, with. Some slug generators strip them automatically to produce shorter, more keyword-dense URLs.

The argument for stripping:

  • Shorter URLs are easier to share verbally and remember
  • Removes redundant words that don't help SEO
  • Older SEO advice suggested keyword density matters

The argument against stripping:

  • Modern search engines understand stop words and don't need them removed
  • Stripped slugs sometimes lose grammatical clarity (how-cook-pasta versus how-to-cook-pasta)
  • Aggressively-stripped slugs can be ambiguous

The modern consensus: don't strip stop words automatically. Let writers decide which words to keep. If a slug is too long, edit the title rather than blindly removing function words.

How long should a slug be?

Search engines display about 50-60 characters of a URL in result snippets before truncating. Slugs longer than that get cut off, which hurts shareability and looks ugly in copy-paste.

The pragmatic rule:

  • Aim for 30-60 characters
  • 3-6 words is usually right
  • Don't sacrifice clarity for shortness
  • Don't pad short slugs with filler

If your title is The 10 Best Italian Restaurants in Chicago for Date Night with a Quiet Atmosphere, your slug should be best-italian-restaurants-chicago or similar — not a literal transcription.

Should slugs include the date?

Some publications include the date in the URL: /2026/04/12/post-title/. Others use date-free slugs: /post-title/.

Including the date in the URL:

  • Communicates recency in search results
  • Allows the same slug to be reused in future years
  • Can hurt SEO for evergreen content (looks dated even if updated)
  • Makes URLs longer

Date-free slugs:

  • Better for evergreen content
  • Require unique slugs across all time
  • Cleaner-looking URLs
  • Easier to share in chat without looking obviously old

For a news site, dates in URLs make sense. For a blog with evergreen content, skip the date.

What about categories in slugs?

Some sites include the category in the slug: /recipes/pasta/spaghetti-carbonara/. Others flatten: /spaghetti-carbonara/.

Categories in URLs:

  • Add hierarchy that helps users navigate manually
  • Provide context in search snippets
  • Make URLs longer and less shareable
  • Tie content to a category — moving an article between categories breaks the URL

If your site has clear, stable categories, including them is fine. If your taxonomy might change, skip them.

Handling slug collisions

If two different articles produce the same slug, you need a uniqueness strategy:

  • Append a number: article-title-2, article-title-3 for duplicates
  • Append a random suffix: article-title-x7 for guaranteed uniqueness
  • Append the date: article-title-2026-04-12
  • Disambiguate manually: write a more specific title or slug for the second article

For low-volume content (blogs), manual disambiguation is best. For high-volume content (e-commerce, user-generated), an automatic suffix is necessary.

What characters are URL-safe?

Per RFC 3986, the safe characters in URL paths are:

  • Letters: A-Z, a-z
  • Digits: 0-9
  • Specific punctuation: -, ., _, ~

Other characters either need percent-encoding (%20 for space, %C3%A9 for é) or shouldn't appear at all.

For slugs specifically, you should use only:

  • Lowercase letters a-z
  • Digits 0-9
  • Hyphens

Avoid underscores in slugs (they're allowed by RFC 3986 but the convention is hyphens). Avoid percent-encoded characters (URLs with % look broken to most users).

Internationalization considerations

Non-Latin scripts (Chinese, Arabic, Hebrew, Russian) have several options for URL slugs:

  1. Use the native script directly: /recipes/羊肉串/. Modern browsers support this; older shares might break.
  2. Use percent-encoded UTF-8: the same URL but with %E7%BE%8A.... Ugly but universal.
  3. Use a Latin transliteration: /recipes/lamb-skewers/. Most readable for international audiences but loses fidelity.
  4. Use an English translation: same as above with full localization.

For multilingual sites, the common pattern is to use English slugs for the canonical URL and provide alternate language paths with hreflang tags.

Slug versus filename

If you're generating static HTML files, the slug typically becomes the filename: /blog/how-to-cook-pasta/ maps to blog/how-to-cook-pasta/index.html. The slug must be filesystem-safe — which is a slightly stricter constraint than URL-safe.

Filesystem-safe means no forward slashes, no characters that need escaping in shell commands, no characters that conflict with Windows reserved names (CON, PRN, NUL, AUX, COM1-9, LPT1-9). The conservative slug rule (lowercase + digits + hyphens only) handles all of these.

Generating slugs in bulk

If you're migrating a site or generating slugs for many articles at once, our bulk converter can take a list of titles and produce slugs in one pass. Each line becomes a slug independently. Suitable for one-time migrations or for generating slug candidates for review.

For individual titles, the slug converter shows you the result instantly as you type.

A practical workflow

When you create a new article:

  1. Write the title first, in title case or sentence case
  2. Generate the slug from the title using a tool or manually
  3. Review for length (30-60 chars) and clarity
  4. Edit the slug if needed — remove stop words only if it improves clarity
  5. Confirm uniqueness across your site
  6. Lock the slug for the lifetime of the article — never change it without a redirect

The "lock the slug" rule is the most important. Changing a slug means existing inbound links (from social shares, other blogs, Google's index) lead to 404 errors. If you must change a slug, set up a 301 redirect from the old URL to the new one.

The bigger picture

Slugs are part of your URL structure, and URL structure is part of your site's identity. A clear, predictable URL pattern helps users navigate, helps search engines understand your site, and helps you reason about your content architecture.

The investment in good slug naming is small per article. The cost of bad slug naming compounds across your entire site over years.