By SitemapFixer Team
Updated May 2026

Underscores vs Hyphens in URLs: The SEO Difference

Google's recommendation on URL word separators has been clear since 2005: use hyphens, not underscores. The reason is technical — Google's indexer treats hyphens as word separators and underscores as word joiners, which affects how your URL keywords are parsed and matched to search queries. This guide explains the mechanism, the real-world SEO impact, how to audit your site for underscore URLs, and how to migrate them safely with 301 redirects.

Check your URLs for underscores and other technical SEO issues in one scanTry SitemapFixer Free

Hyphens vs Underscores: The Core Difference

The fundamental difference between hyphens and underscores in URLs comes down to how Google's text tokenization treats them. A hyphen (-) acts as a word boundary — it tells Google's parser that the characters on each side are separate words. An underscore (_) acts as a word joiner — it tells Google's parser that the characters on both sides form a single compound token. This behavior is inherited from how these characters function in programming and natural language processing contexts.

In practical terms: the URL /page-speed-optimization is read as three words — "page", "speed", and "optimization" — each of which can independently match search query terms. The URL /page_speed_optimization is read as one token — "page_speed_optimization" — which matches almost nothing in typical search queries because users don't type underscores. The page-speed variant has three times the keyword matching surface area compared to its underscore equivalent.

This distinction is not specific to Google — Bing and other search engines apply the same word-segmentation logic. Web standards bodies have historically treated hyphens as word separators in text processing, making the behavior consistent across the search ecosystem. Hyphen-separated URLs also tend to be more readable for human users, which has UX benefits for click-through from SERPs and shared links.

Google's Official Position

Google's recommendation for hyphens over underscores in URLs dates to at least 2005 in their early Webmaster Guidelines documentation. The most-cited reference is a 2011 video by Matt Cutts — then head of Google's Webspam team — in which he explicitly stated that Google treats hyphens as word separators but underscores as word joiners, recommending that site owners use hyphens in URL slugs. That video was watched millions of times and remains a foundational reference in technical SEO.

More recently, John Mueller — Google's Search Advocate — has confirmed this position in multiple Google Search Central office hours sessions and community forum replies. Mueller has noted that while this is not a make-or-break ranking factor, it is a genuine best practice with a real (if modest) impact on how URLs contribute to keyword matching. Google's own URL structure documentation continues to recommend hyphens as word separators in slug design.

It is worth noting that Google has also stated they are working to improve handling of underscores in URLs, and future updates may reduce the gap. However, since hyphens are the explicit recommendation and there is no downside to using them, there is no reason to rely on future algorithmic changes — build with hyphens from the start.

The Practical SEO Impact

The SEO impact of underscores vs hyphens is real but should be kept in proportion. For most pages, this is a minor ranking factor — it will not be the sole reason a page ranks or fails to rank. However, in competitive keyword markets where pages are closely matched on all major signals (backlinks, content quality, page speed, E-E-A-T), URL structure can be a tiebreaker. Pages with hyphenated URLs have a slight advantage in keyword matching that can translate to marginally better impressions for the target keywords.

The impact is more pronounced for long-tail keywords where individual word matching matters more. A URL like /best-running-shoes-for-flat-feet benefits from matching any combination of those six words, while /best_running_shoes_for_flat_feet matches only as a full underscore-joined token that virtually no user will ever type. For sites targeting hundreds of long-tail keywords through URL structure — as many programmatic SEO projects do — switching from underscores to hyphens across the board can produce measurable aggregate traffic improvements.

For new sites or new content sections, the decision is simple: always use hyphens. The cost is zero, the benefit is genuine, and there is no technical reason to prefer underscores in URL slugs. For existing sites with established underscore URLs, the analysis is more nuanced — migration has costs, and the expected benefit must exceed those costs before the work is justified.

Real-World Examples

Consider two URLs competing for the query "page speed optimization": /page-speed-optimization and /page_speed_optimization. Google tokenizes the first as ["page", "speed", "optimization"] — three separate keywords that independently contribute to relevance for queries containing any of those words. The second tokenizes as ["page_speed_optimization"] — one compound token that only matches the full underscore-joined string, which real users never type.

Another illustrative example: a site selling running shoes that uses /mens_running_shoes_size_10 as a URL structure. Google parses this as one long token. A competitor using /mens-running-shoes-size-10 gets keyword matching for "mens", "running", "shoes", "size", and "10" individually, giving the page relevance for far more query variations including "mens running shoes", "running shoes size 10", and "mens shoes size 10". The hyphen URL has substantially more organic query coverage from the URL alone.

The effect compounds across large sites. An e-commerce site with 10,000 product pages using underscored URLs is effectively hiding its keyword signals in 10,000 URLs that could otherwise contribute to query matching. After migrating to hyphens with proper 301 redirects, sites in this situation commonly report measurable improvements in organic impressions within 4–8 weeks of Google reindexing the new URLs.

How to Check Your Site for Underscore URLs

The most thorough method is a full site crawl with Screaming Frog SEO Spider. After crawling, open the URL column in the Internal tab and use the Filter to search for underscore characters. Export the results to identify every underscore URL on your site, along with its HTTP status code, page title, and number of inbound internal links. Sort by inbound links to prioritize the most-linked pages for migration first.

In Google Search Console, go to Coverage and export all indexed URLs. In a spreadsheet, use a formula to filter any URL containing an underscore in the path segment (excluding query parameters, which are a separate consideration). This shows you exactly which underscore URLs Google has already indexed and is counting for your site — these are your highest-priority migration targets because they already have established ranking signals.

SitemapFixer will flag underscore URLs when scanning your XML sitemap or crawling your site, grouping them as a technical SEO issue with count and severity. This makes it easy to get a quick overview of your underscore URL exposure before committing to a full Screaming Frog crawl. Cross-reference the sitemap report with your GSC export to confirm which underscore URLs are both submitted and indexed.

When to Fix Underscore URLs

For new sites or new sections being built, the answer is unambiguous: always use hyphens from the start. There is no migration cost, no risk of losing backlinks, and no disruption to existing rankings. Set your CMS, framework, or routing configuration to generate hyphenated slugs by default and this decision never needs to be revisited.

For existing sites with established underscore URLs, the cost-benefit calculation is more complex. Pages with significant organic traffic, backlinks from high-authority sites, and many internal links will have accumulated ranking signals tied to their current URLs. A migration requires 301 redirects, sitemap updates, internal link updates, and canonical tag verification — all of which take engineering time. The question to ask is: how much organic traffic improvement do we expect, and does that justify the migration cost and temporary disruption?

A practical prioritization framework: migrate high-traffic, keyword-critical pages first. If a page ranks on page two for a competitive keyword and switching to hyphens might push it to page one, the ROI is clear. Pages already ranking at position one or two have less to gain — the hyphen change might provide marginal benefit, but disrupting a top-ranking URL always carries some risk of temporary ranking drop during reindexing. For lower-traffic pages, batch the migration and run it as a maintenance task rather than an urgent project.

Setting Up 301 Redirects for Underscore-to-Hyphen Migration

When migrating underscore URLs to hyphen equivalents on an Apache server, you can use a RewriteRule in your .htaccess file to handle the redirect automatically for any URL containing underscores. The rule below uses a recursive approach — since a URL can contain multiple underscores, the [L] (last) flag stops processing after the first match, and repeated requests work through remaining underscores. For production use, test this rule in a staging environment first:

RewriteEngine On
RewriteRule ^(.*)_(.*)$ /$1-$2 [R=301,L,NE]

This rule matches any URL containing an underscore between two captured groups and redirects to the same URL with a hyphen, using a 301 permanent redirect. The NE flag prevents special characters from being encoded in the redirect target. Note that this regex only handles one underscore per invocation — for URLs with multiple underscores, the browser follows the chain of redirects until no underscores remain, which is typically two to three hops at most. For cleaner handling, generate an explicit redirect map from your full URL audit and implement one direct redirect per old URL to its final hyphenated destination.

On Nginx, use individual return 301 directives or a map block for URL-specific redirects. On Node.js or Next.js applications, add redirect rules to your next.config.js redirects array or middleware. After implementing redirects, verify each one using curl with the -I flag to confirm the correct 301 status code and Location header before submitting the new URLs in Google Search Console.

CMS-Specific Settings

WordPress generates URL slugs from post titles, and by default uses hyphens — so most WordPress sites already follow best practice. However, some older WordPress installs or custom post type configurations may have been set up to use underscores. Check Settings > Permalinks to ensure your permalink structure uses hyphen-separated slugs. For existing posts with underscore slugs, the Redirection plugin (free, by John Godley) lets you manage the redirects from old URLs without touching .htaccess directly.

Shopify presents a limitation: product handles (the URL slug) accept hyphens natively, but Shopify does not allow you to change the URL format for collections or products after creation without losing the canonical URL. If your Shopify store was originally set up with underscore product handles, you will need to create new products with hyphenated handles and redirect the old URLs — a more involved process than a simple .htaccess rule. Shopify's URL redirect feature (Online Store > Navigation > URL Redirects) handles 301s within the platform.

Other platforms: Squarespace uses hyphens by default and does not expose underscore URL options. Wix allows custom URL slugs and defaults to hyphens in its editor. Webflow generates hyphenated slugs automatically from page names. Django and Ruby on Rails applications require code-level changes to URL routing patterns — update your URL pattern definitions and add URL rewrites at the server level to handle old underscore URLs permanently.

Underscores in Query Parameters: Fine to Use

The hyphens-vs-underscores rule applies specifically to the path segment of a URL — the slug portion that appears before any question mark. Query parameters (the key=value pairs after the ? character) are not subject to the same word-parsing behavior. Using underscores in parameter names like ?sort_by=price or ?filter_color=red has no SEO impact because Google does not use query parameter names as keyword signals in the same way it uses path segments.

Similarly, underscores in file extensions, tracking parameters, or internal system identifiers in the query string are irrelevant to organic rankings. The concern is exclusively with the URL path — the segment between the domain and any question mark. If your URL is /product-detail?item_id=12345, the path segment uses a hyphen correctly and the underscore in the parameter name is a non-issue.

One important exception: if your CMS creates URLs where filter values appear in the path rather than as query parameters — for example /shoes/color_red/size_10 — then those underscores in the path segment do affect keyword parsing and should be addressed. This is a common pattern in older Magento and custom e-commerce implementations. Identify whether your filter URLs use path segments or query parameters and apply the underscore fix only where it is in the path.

Canonical Tags as an Alternative

If you cannot implement 301 redirects for technical or organizational reasons — for example, a legacy system with no redirect management capability or a platform that doesn't support custom server redirects — canonical tags offer a partial alternative. Add a canonical tag to each underscore URL pointing to the equivalent hyphen URL: this tells Google which version to index and credit for rankings, even if both URLs remain accessible.

The limitation of this approach is that canonical tags are hints, not directives. Google may choose to respect them or ignore them, especially if the underscore URL has strong independent signals like many direct backlinks. A 301 redirect is always more reliable than a canonical tag for consolidating ranking signals, because redirects are enforced at the HTTP response level while canonical tags are an on-page suggestion that Google can override.

Use the canonical approach only as a temporary measure while engineering work to implement proper redirects is planned, or as a permanent solution only when redirects are genuinely impossible. In both cases, ensure the canonical tag on the underscore URL points to a live, 200-status hyphen URL — not to another redirect or a 404. Also update your XML sitemap to include only the canonical (hyphenated) URLs so Google receives a consistent signal from both the sitemap and the on-page canonical tag.

Audit Your URLs for Underscores and Other Technical Issues
Scan your sitemap and site for URL structure problems in 60 seconds
Try SitemapFixer Free

Related Guides