How to Generate a Slug for URLs and Blog Posts
Every blog post and content page has a slug — the human-readable identifier at the end of the URL. A good slug is short, clear, and permanent. A bad slug is auto-generated gibberish, a full title with every stop word included, or — worst — a numeric ID that tells no one anything.
What a slug is
The slug is the final path segment of a URL:
https://veratools.io/guides/how-to-generate-a-slug-for-urls-and-blog-posts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
slug
The term comes from newspaper typesetting — a slug was a line of metal type used to identify a story in production. In web publishing, it became the standard term for the URL identifier of a piece of content.
The rules for a good slug
- Lowercase only. URLs are case-sensitive on most servers.
/How-Toand/how-tocan be different pages. Lowercase eliminates the ambiguity. - Hyphens between words. Google treats hyphens as word separators — they help search engines read the slug as individual words. Underscores don't get the same treatment in Google's indexing. Spaces get encoded as
%20, which is unreadable. - Letters, numbers, hyphens only. Accented characters, punctuation, and special characters either need percent-encoding or cause problems. Transliterate accented characters (é → e, ü → u) rather than encoding them.
- Short but meaningful. Include the keywords that identify the content. Drop stop words (the, a, an, of, for, and, in, to) unless they're essential to meaning.
- No leading or trailing hyphens.
-how-to-is invalid;how-tois correct.
"How to Generate a Slug for URLs and Blog Posts"
→ how-to-generate-a-slug-for-urls-and-blog-posts
"Björk's Favorite Café in Reykjavík"
→ bjorks-favorite-cafe-in-reykjavik
"10 Best Ways to Improve Your Morning Routine"
→ improve-morning-routine (or keep: ten-best-morning-routine-tips)
SEO impact of slug quality
Slugs appear in search results — the URL is displayed under the page title. A URL like /p?id=4827 conveys nothing. A slug like /how-to-generate-a-slug tells both users and search engines exactly what the page covers before they click.
Keywords in the URL path are a search ranking signal. It's weaker than keywords in the title and content, but it contributes. More importantly, a descriptive URL gets more clicks in search results because it confirms that the page matches the user's intent.
Common mistakes
Using the full title verbatim. "The 10 Best Ways to Dramatically Improve Your Daily Morning Routine in 2026" becomes a 75-character slug with every stop word included. Drop the stop words and date: improve-morning-routine or morning-routine-tips.
Including dates in slugs for evergreen content. 2024-01-15-how-to-write-a-slug looks stale in 2026. Use dates only for genuinely time-indexed content like news articles.