Skip to main content
Beta: Front-End Checklist is currently in beta. Some issues are still being fixed. Thanks for your patience.
SEOMedium

Use hyphens in URLs

Checks that URL slugs use hyphens as word separators, not underscores or spaces

Utilities
Quick take
Typical fix time 10 min
  • 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
Why it matters: Google's search systems interpret hyphens in URLs as word boundaries, enabling it to match the URL against individual keyword queries. Underscores join words into a single token, meaning `/seo_practices` is seen as one word 'seopractices' rather than two separate words 'seo' and 'practices'.

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-practices matches queries for "best seo practices", "seo practices", and "best practices". /best_seo_practices matches 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:

  1. Export all current underscore URLs from your sitemap or crawl
  2. Generate the hyphenated equivalents
  3. Implement 301 redirects for each old URL
  4. Update all internal links to use the new URLs
  5. Update the sitemap.xml
  6. Request re-indexing in Google Search Console
  7. 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.

Sources

References used to support the guidance in this rule.

Further Reading

Tools and supplementary material for exploring the topic in more depth.

URL Structure Best Practices for Google Search | Google Search Central  |  Documentation  |  Google for Developers

It's a good idea to keep your site's URL structure as simple as possible. Learn more about the URL format recommended by Google, such as the use of hyphens, und…

Google for DevelopersGuide
URL Structure Best Practices for Google Search | Google Search Central  |  Documentation  |  Google for Developers

It's a good idea to keep your site's URL structure as simple as possible. Learn more about the URL format recommended by Google, such as the use of hyphens, und…

Google for DevelopersGuide

Rules that often go hand-in-hand with this one.

Use lowercase URLs

Checks that URLs are lowercase

SEO
Keep URLs concise

Checks URL length for optimal crawlability and usability

SEO
Link directly to final destination URLs

Detects URLs that redirect and links pointing to redirects

SEO
URL Stop Words

Flags common stop words in URL slugs that add length without improving keyword relevance.

SEO

Was this rule helpful?

Your feedback helps improve rule quality. This stays internal for now.

Loading feedback...
0 / 385