Use hyphens in URLs
Checks that URL slugs use hyphens as word separators, not underscores or spaces
- Use hyphens (`-`) to separate words in URLs — Google treats hyphens as word separators, underscores as part of the word
- `/best-seo-practices` is better than `/best_seo_practices` or `/bestseopractices`
- Changing existing URLs from underscores to hyphens requires 301 redirects to preserve link equity
Rule Details
Google explicitly recommends hyphens over underscores as word separators in URLs. This is because Google's tokeniser treats hyphens as word breaks and underscores as word joiners.
Code Examples
❌ Avoid — underscores in URL slugs
/blog/seo_best_practices
/products/product_name_here
/docs/api_reference_guide❌ Avoid — spaces or encoded spaces
/blog/seo best practices (invalid)
/blog/seo%20best%20practices (browsers handle but not ideal)
/blog/seo+best+practices (query string convention, not path)✅ Correct — hyphens throughout
/blog/seo-best-practices
/products/product-name-here
/docs/api-reference-guide✅ Slug generation function
function toSlug(title) {
return title
.toLowerCase()
.trim()
.replace(/[^\w\s-]/g, '') // Remove special characters
.replace(/[\s_]+/g, '-') // Replace spaces and underscores with hyphens
.replace(/^-+|-+$/g, '') // Remove leading/trailing hyphens
}
toSlug('SEO Best Practices (2024)') // → 'seo-best-practices-2024'
toSlug('API_Reference_Guide') // → 'api-reference-guide'✅ 301 redirect for underscore to hyphen migration
# Nginx: redirect underscore URLs to hyphenated equivalents
rewrite ^/blog/(.*)_(.*)$ /blog/$1-$2 permanent;
# Or use a more general map approach
map $uri $new_uri {
~/blog/seo_best_practices /blog/seo-best-practices;
}// Next.js: redirects in next.config.js
module.exports = {
async redirects() {
return [
{
source: '/blog/seo_best_practices',
destination: '/blog/seo-best-practices',
permanent: true,
},
]
},
}Why It Matters
- Keyword matching:
/best-seo-practicesmatches queries for "best seo practices", "seo practices", and "best practices"./best_seo_practicesmatches only "best_seo_practices" as a compound token. - Readability: Hyphenated URLs are easier to read, copy, and share, which affects click-through rates.
- Consistency: Mixing separators (some with hyphens, some with underscores) creates duplicate content risk.
Migration Checklist
When migrating from underscores to hyphens:
- Export all current underscore URLs from your sitemap or crawl
- Generate the hyphenated equivalents
- Implement 301 redirects for each old URL
- Update all internal links to use the new URLs
- Update the sitemap.xml
- Request re-indexing in Google Search Console
- Monitor for 404s in Search Console for 3–4 weeks post-migration
Exceptions
- Necessary utility or compliance pages can be intentionally brief and should not be judged by the same editorial-depth expectations as ranking-focused content.
- AI-assisted drafting is not a failure by itself; flag unsupported claims, missing editorial review, or low-originality output instead.
- When a page has both trust-signal issues and crawl/index problems, make the page eligible to rank first and then improve the content quality signals.
Verification
Automated Checks
- Inspect rendered HTML and HTTP headers to confirm the expected metadata or crawlability signal is present.
- Test the affected URL with Google Search Console or equivalent tooling where relevant.
- Re-crawl a representative page set after deployment.
Manual Checks
- Confirm the change does not create conflicting canonical-url, robots, or structured-data signals.
Use with AI
Copy these prompts to use with your AI assistant, or install the MCP server to use directly from Claude, Cursor, or Windsurf.
Check
Verify implementation
Inspect the URL path segment of each page. Flag any URL that contains: (1) Underscores (`_`) as word separators (e.g., `/best_practices`). (2) Spaces encoded as `%20` or `+` in path segments. (3) Mixed separators in the same URL (e.g., `/best-practices_guide`). Report the count of non-hyphenated URLs by category.
Fix
Auto-fix issues
1. Identify all pages with underscores or spaces in URL path segments. 2. Generate the hyphenated equivalent: replace `_` with `-`, spaces/`%20` with `-`. 3. Set up 301 permanent redirects from the old URLs to the new hyphenated URLs. 4. Update internal links throughout the site to point to the new URLs. 5. Submit the new URLs to Google Search Console for re-indexing. 6. Update your sitemap.xml to include only the new hyphenated URLs. 7. In your CMS or slug-generation function, enforce hyphens going forward: - Slug: title.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '')
Explain
Learn more
Google's John Mueller has confirmed that Google interprets hyphens as word separators in URLs, but treats underscores as word joiners. This means a URL with underscores matches fewer individual keyword queries. For example, `/web_design` would match 'web_design' as a single token, while `/web-design` matches both 'web design' and 'webdesign' queries.
Review
Code review
Parse all URL paths used in the application's router or CMS slug fields. Flag any path segment containing `_` characters between words or any `%20` space encoding. Verify slug-generation utilities produce lowercase hyphenated output. Check redirect rules to confirm old underscore URLs are permanently (301) redirected to their hyphenated equivalents.
