What is a Slug?
A slug is the URL-friendly identifier derived from a page title. The title "What is a Slug?" becomes the slug what-is-a-slug — lowercase, spaces replaced with hyphens, special characters removed.
How a Slug Is Generated
Given the title "Hello, World! (2024)", a slug generator applies these steps:
- Lowercase:
hello, world! (2024) - Replace spaces with hyphens:
hello,-world!-(2024) - Remove non-alphanumeric characters (keep hyphens):
hello-world-2024 - Collapse consecutive hyphens:
hello-world-2024 - Trim leading/trailing hyphens:
hello-world-2024
For non-ASCII characters (accented letters, CJK, Arabic), the best practice is to transliterate to ASCII first — e.g. é → e, ü → u.
Hyphens vs Underscores
Google's John Mueller has confirmed hyphens are preferred over underscores in slugs. A hyphen acts as a word separator in search indexing; an underscore does not. best-coffee-shops is indexed as three separate words; best_coffee_shops is a single token.
Where Slugs Are Used
- Blog and CMS URLs:
/blog/what-is-a-slug - Product pages:
/products/blue-denim-jacket - Category and tag pages
- API endpoints:
/api/users/john-doe - Git branch names (by convention)
Generate a URL slug from any text: Open Slug Generator →
Frequently Asked Questions
Should slugs include stop words?
It depends. Short slugs are cleaner (/blog/slug-guide) but longer descriptive slugs match more search queries (/blog/what-is-a-url-slug). For SEO, include the target keyword; remove truly meaningless filler words like "a", "the", "is" only if the slug is excessively long.
Can I change a slug after publishing?
You can, but it breaks existing links and resets any SEO equity unless you set up a 301 redirect from the old slug to the new one. Change slugs sparingly on established pages.
Related Terms
- URL Encoding — How special characters are safely encoded in URLs.
- HTTP Redirects — How to handle slug changes without breaking links.