What is a Slug? — URL Slugs Explained
Definition
A slug is the URL-friendly portion of a web address that identifies a specific page or resource in a human-readable way. Slugs are made up of lowercase letters, numbers, and hyphens, with spaces and special characters replaced or removed. For example, the blog post "What is a URL Slug?" might have the slug "what-is-a-url-slug". Well-crafted slugs improve URL readability, help search engines understand page content, and remain stable links when page titles change.
How It Works
Generating a slug from a title involves: converting to lowercase, replacing spaces with hyphens, removing or replacing characters that are not letters, numbers, or hyphens (using transliteration for accented characters like é→e, ñ→n), collapsing multiple consecutive hyphens into one, and trimming leading/trailing hyphens. For Unicode titles in non-Latin scripts, the transliteration step is critical — "François" becomes "francois" and "日本語" becomes a transliterated equivalent. CMS platforms like WordPress, Ghost, and headless CMS tools generate slugs automatically.
Common Use Cases
- ▸Blog post and article URLs (/blog/what-is-a-url-slug)
- ▸Product page URLs in e-commerce (/products/blue-running-shoes-mens)
- ▸Category and tag URLs in CMS-driven sites
- ▸Creating stable IDs for user-created content from display names
- ▸File naming conventions for assets and documentation
Example
Title: "Hello, World! This is my 1st blog post." Slug: "hello-world-this-is-my-1st-blog-post" Title: "François & the Résumé" Slug: "francois-and-the-resume" Title: "Top 10 Node.js Tips & Tricks" Slug: "top-10-nodejs-tips-and-tricks"
Related Tools
FAQ
- Should I use hyphens or underscores in slugs?
- Use hyphens. Google treats hyphens as word separators in URLs, so "my-page" is treated as "my page" for search purposes. Underscores are treated as word joiners, so "my_page" is a single word "mypage" for Google. Hyphens also look cleaner in browser address bars.
- Can I change a slug after publishing?
- Avoid changing slugs after publishing because the old URL will return a 404. If you must change a slug, set up a permanent 301 redirect from the old URL to the new one to preserve SEO value and user bookmarks.
- How long should a slug be?
- Keep slugs concise — typically 3 to 6 meaningful words. Remove stop words like "a", "the", "and", "of" to keep the URL shorter. Long slugs are harder to share, read, and type. Most SEO guidance recommends slugs under 60 characters.