URL Slug Best Practices
What makes a good slug
A slug is the human-readable part of a URL. Good slugs are lowercase, hyphen-separated, ASCII, short enough to read in a search result, and stable once published. They should describe the page well enough that the URL alone tells you what it contains.
Before and after
Real titles turned into slugs, with the reasoning:
10 Best Ways to Validate JSON in 2026!→validate-json— drop the year so the URL survives next year's update, drop filler.Café & Résumé Tips→cafe-resume-tips— accents folded to ASCII, ampersand removed.How do I decode a JWT?→decode-jwt— question words add length without meaning.Product #A-1200 (New)→product-a-1200— punctuation stripped, single hyphens kept.أدوات مجانية للمطورين→free-developer-tools— transliterating Arabic gives an unreadable slug; translate the key phrase instead, or keep the Arabic and let the browser percent-encode it if your audience is Arabic-speaking.
Rules to encode in your slugify function
A robust slugifier applies these steps in order:
- Unicode-normalise (NFKD) and strip combining marks so
ébecomese. - Lowercase the whole string — mixed-case URLs create duplicate paths on case-sensitive servers.
- Replace every run of non-alphanumeric characters with a single hyphen.
- Trim leading and trailing hyphens.
- Cap the length at roughly 60 characters, cutting on a hyphen rather than mid-word.
- Guard against empty results and reserved words such as
new,editorapithat collide with your routes.
Stop words, dates and IDs
Removing a, the and of shortens slugs harmlessly, but do not remove words that carry meaning — how-to and vs are often the search phrase itself. Avoid dates in slugs unless the page is genuinely time-bound news; a dated URL signals staleness the moment the year turns.
For user-generated content, append a short unique suffix (my-post-4f9c) instead of a bare counter. It guarantees uniqueness without exposing how many records you have.
Changing a slug after publishing
A published slug is an address other people link to. If you must change it, serve a 301 redirect from the old path to the new one and keep it indefinitely, update internal links to point directly at the new URL, and refresh the sitemap. Skipping the redirect drops whatever ranking and referral traffic the old URL had earned.
Slug depth and structure
Keep paths shallow: /guides/validate-json beats /blog/2026/08/dev/tools/validate-json. One meaningful directory level plus the slug is enough for most sites, and it keeps the breadcrumb, canonical URL and analytics grouping simple.
Generate a slug now
Turn any title into a clean slug with the Slug Generator, then check the wider URL pattern against the SEO-friendly URL structure guide and finish the page metadata with the Meta Tag Generator.
Try the Slug Generator →Turn any title into a clean, SEO-friendly URL slug. Choose the separator, limit words, strip accents and stop words. Free online slugify tool.Frequently asked questions
Should slugs use hyphens or underscores?
Hyphens. Search engines treat hyphens as word separators and underscores as joiners.
How long should a slug be?
Three to five meaningful words, under about 60 characters, so it stays fully visible in search results.
Can a slug contain Arabic or accented characters?
Technically yes via percent-encoding, and it can help native-language audiences — but the encoded form is ugly when copied. ASCII slugs are the safer default.