Last updated
Slug Rules Summary
- Lowercase only — no uppercase letters
- Hyphens to separate words — no spaces, underscores, or other separators
- Alphanumeric characters and hyphens only — no special characters
- No leading or trailing hyphens
- No consecutive hyphens
- 3–60 characters recommended
- Descriptive and keyword-rich — avoid stop words when possible
- ASCII only — transliterate non-ASCII characters
- Unique within your site — no duplicate slugs
Slug Migration Checklist
When changing an existing slug, always set up a 301 redirect from the old URL to the new one:
# Nginx redirect
location = /old-slug {
return 301 /new-slug;
}
# Apache .htaccess
Redirect 301 /old-slug /new-slug
# Next.js redirects in next.config.js
module.exports = {
async redirects() {
return [
{ source: '/old-slug', destination: '/new-slug', permanent: true }
];
}
};
Examples
Example 1: Valid Slugs
✓ getting-started-with-react
✓ how-to-build-a-rest-api
✓ product-name-blue-xl
✓ 10-tips-for-better-code
✓ javascript-array-methods
✓ contact-us
✓ about
Example 2: Common Validation Errors and Fixes
INVALID: "Getting Started With React"
Issues: uppercase letters, spaces
Fixed: "getting-started-with-react"
INVALID: "how_to_build_a_REST_API"
Issues: underscores, uppercase letters
Fixed: "how-to-build-a-rest-api"
INVALID: "product--name--here"
Issues: multiple consecutive hyphens
Fixed: "product-name-here"
INVALID: "-leading-hyphen"
Issues: leading hyphen
Fixed: "leading-hyphen"
INVALID: "trailing-hyphen-"
Issues: trailing hyphen
Fixed: "trailing-hyphen"
INVALID: "what's-new-in-2026?"
Issues: apostrophe, question mark (special characters)
Fixed: "whats-new-in-2026"
INVALID: "café-au-lait"
Issues: non-ASCII character (é)
Fixed: "cafe-au-lait" (transliterated)
or: "caf%C3%A9-au-lait" (percent-encoded — less readable)
Example 3: SEO Best Practice Checks
Slug: "the-best-way-to-learn-javascript-programming-for-beginners-in-2026"
Length: 68 characters
Warning: Slug is too long (over 60 characters). Consider shortening.
Suggestion: "learn-javascript-for-beginners-2026"
Slug: "a"
Length: 1 character
Warning: Slug is too short to be descriptive.
Suggestion: Use at least 3 characters.
Slug: "the-a-and-of-in-to"
Warning: Slug consists mostly of stop words with no meaningful keywords.
Suggestion: Remove stop words and focus on the key topic.