What is a URL Slug? Complete Guide with Examples
A URL slug is the human-readable part of a URL that identifies a specific page, typically derived from the page title. For example, in 'example.com/blog/what-is-url-slug', the slug is 'what-is-url-slug'. Good slugs are lowercase, use hyphens to separate words, contain no special characters, and clearly describe the page content for both users and search engines.
How Does URL Slug Work?
Slug generation converts a title or phrase into a URL-safe string by lowercasing all characters, replacing spaces and special characters with hyphens, removing non-alphanumeric characters, collapsing consecutive hyphens into one, and trimming leading/trailing hyphens. Advanced generators also transliterate accented characters (é→e, ü→u), handle CJK characters, remove stop words (the, a, an, in), and enforce maximum length limits.
Key Features
- Automatic conversion from titles to clean, URL-safe slugs
- Transliteration of accented and special characters to ASCII equivalents
- Stop word removal to create shorter, more focused slugs
- Configurable separator character (hyphen, underscore, or dot)
- Maximum length enforcement to keep URLs concise
Common Use Cases
Blog Post URLs
CMS platforms generate slugs from post titles to create clean, descriptive URLs like '/blog/10-tips-for-better-seo' instead of '/blog/post?id=12345'.
E-commerce Product URLs
Online stores use slugs for product pages: '/products/blue-cotton-t-shirt' is more SEO-friendly and user-readable than '/products/SKU-12345'.
API Resource Identifiers
REST APIs often use slugs as human-readable identifiers for resources alongside numeric IDs, making API endpoints more intuitive: '/api/categories/web-development'.