Check 02.10 · Architecture and navigation

Separate words with hyphens

Separate the words in your URLs with hyphens rather than underscores or spaces, configure your CMS accordingly and redirect old addresses cleanly.

Priority
Critical
Difficulty
Easy
Estimated time
15 min to 1 day
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

In a URL, words are separated by a hyphen (-): /guides/choisir-the-vert/, not /guides/choisir_the_vert/, /guides/choisirthevert/ or /guides/choisir%20the%20vert/. This is Google's explicit recommendation and the convention of every current CMS. Once the check is done, all new URLs are generated with hyphens, and old URLs with underscores are either kept deliberately or redirected with a 301 to their new form.

Why it matters

Google says it plainly in its documentation on URL structure: use hyphens to separate words rather than underscores, and do not run words together. A hyphen makes each word readable for search engines and humans alike; an underscore, joined-up words or a space encoded as %20 blur that reading.

A URL is also text that people see: in search results, in a link shared by email or on social media, in the sources cited by an AI assistant. /pompe-a-chaleur-air-eau/ is understood at a glance; /pompe_a_chaleur_air_eau/ reads poorly when the link is underlined, because the underline hides the underscores.

Finally, a single rule prevents duplicates: the same article published once at /mon-article/ and once at /mon_article/ creates two URLs that compete with each other.

Good to know: an underscore carries little weight in rankings. On an established site, changing hundreds of URLs for this reason alone often costs more than it brings: redirects to maintain, signals to consolidate again, external links pointing to the old address. Apply the rule to everything new, and only fix existing URLs if they get little visibility or during a redesign.

What it improves

  • URL readability In search results, shares and AI assistant citations. The effect on click-through rate is plausible but unmeasured.
  • Word recognition Each term in the slug stands on its own, as Google recommends.
  • Consistency A single generation rule prevents duplicates such as /mon-article/ and /mon_article/.
  • Typing and recall A URL read out loud or retyped gets passed on without errors.
  • Rankings Little direct effect. Do not start a URL migration for this reason alone.

How to check

Find URLs that contain an underscore, an encoded space or a +, starting from the sitemap:

curl -s https://example.com/sitemap.xml | grep -oE "<loc>[^<]+</loc>" | sed -E 's#</?loc>##g' | grep -E "_|%20|\+"

If the file is a sitemap index, run the same command on each of the sitemaps it lists. No output lines: the sitemap passes.

Other ways:

  • Screaming Frog: after the crawl, URL tab, filters “Underscores”, “Contains A Space” and “Uppercase”. The free version is enough for up to 500 URLs.
  • Search Console: in the Performance report, Pages tab, filter on “URLs containing _” to find out which underscore pages actually get traffic before deciding to change them.

Passing result: new pages have hyphenated slugs, and every remaining underscore URL is either kept on purpose or redirected in a single hop to its hyphenated version.

How to implement

Before you start

Slug-building rule, to give to writers and apply in the code:

Rule Example title Resulting slug
Hyphens between words Choisir un thé vert choisir-the-vert
Lowercase, no accents or punctuation Thé vert : bienfaits & préparation the-vert-bienfaits-preparation
No double hyphen, none at the start or end – Offre spéciale – offre-speciale
Stop words removed if the slug stays clear Comment entretenir sa chaudière entretenir-chaudiere

The last two rules are conventions, not search engine requirements. For slug length and stability, see create short, stable and descriptive URLs (opens in a new tab).

For existing URLs, decide one URL at a time:

  • Page with little visibility and no external links: change the slug and redirect with a 301.
  • Page that gets traffic or external links: keep the URL as it is, unless a redesign is planned. See keep high-performing URLs if possible (opens in a new tab).
  • After each change: update internal links, the sitemap and the canonical so they point directly to the new URL, without going through the redirect.

Warning: a generic redirect rule (every underscore becomes a hyphen) must not touch files: photo_1.jpg or catalogue_2026.pdf would become 404s. The rules below exclude paths that contain a dot.

Apache

Versions Apache 2.4.

In the .htaccess file at the root, before the CMS rules, this block replaces every underscore in a path without an extension and redirects once with a 301:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^([^_.]*)_([^_.]*_[^.]*)$ $1-$2 [N]
    RewriteRule ^([^_.]*)_([^_.]*)$ /$1-$2 [R=301,L]
</IfModule>

The first rule replaces underscores one by one and restarts processing ([N]) as long as more than one remains; the second replaces the last one and redirects. URL parameters are preserved. In the virtual host configuration, add a slash at the start of the patterns (^/([^_.]*)…) and remove the slash from the target ($1-$2).

If only a few URLs are affected, prefer explicit redirects, which are easier to review:

Redirect 301 /guides/choisir_the_vert/ https://example.com/guides/choisir-the-vert/
Redirect 301 /services/entretien_chaudiere/ https://example.com/services/entretien-chaudiere/

Test, then reload: sudo apachectl configtest && sudo systemctl reload apache2.

Nginx

Versions Nginx 1.24 and later.

Nginx cannot loop over a replacement. This block, inside the server block, handles up to three underscores in a single redirect, and any further ones in an extra hop:

location ~ "^/[^.]*_[^.]*$" {
    rewrite "^([^_]*)_([^_]*)_([^_]*)_([^_]*)$" $1-$2-$3-$4 permanent;
    rewrite "^([^_]*)_([^_]*)_([^_]*)$" $1-$2-$3 permanent;
    rewrite "^([^_]*)_([^_]*)$" $1-$2 permanent;
    rewrite "^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$" $1-$2-$3-$4-$5 permanent;
}

permanent returns a 301 and keeps the parameters. For a fixed list of URLs, a lookup table is safer:

# http context
map $uri $nouvelle_url {
    /guides/choisir_the_vert/        /guides/choisir-the-vert/;
    /services/entretien_chaudiere/   /services/entretien-chaudiere/;
}

# server block
if ($nouvelle_url) {
    return 301 $nouvelle_url$is_args$args;
}

Reload with sudo nginx -t && sudo systemctl reload nginx.

Cloudflare

Versions Cloudflare dashboard, all plans, November 2026.

Dynamic redirects using regular expressions (Single Redirects with regex_replace()) are limited to the Business and Enterprise plans. On the Free and Pro plans, use Bulk Redirects, available on all plans (10,000 redirects on the Free plan): at account level, create a redirect list, import the old URL and new URL pairs (CSV import is possible), choose the 301 status code, then create the Bulk Redirects rule that enables the list. The exact CSV file format is described in the Cloudflare documentation.

On Business or Enterprise, a dynamic redirect rule replaces one underscore per pass: keep it for cases where each URL contains only one, or handle the redirect at the origin.

Plesk

Versions Plesk Obsidian 18.0.

With Apache behind Nginx (Plesk's default configuration on Linux), paste the block from the Apache section into the .htaccess file using File Manager. If the site runs on Nginx alone, open Websites & Domains > your domain > Apache & nginx Settings and paste the location block from the Nginx section, or a per-URL redirect, into “Additional nginx directives”:

location = /guides/choisir_the_vert/ {
    return 301 /guides/choisir-the-vert/;
}

The map directive cannot go in this field, which is inserted into the server block.

cPanel

Versions cPanel, Jupiter theme, November 2026.

For a few URLs, Domains > Redirects creates 301 redirects one at a time and writes them to the .htaccess file. For a generic rule, paste the block from the Apache section into public_html/.htaccess using File Manager.

Shared hosting

The .htaccess block from the Apache section works with most Apache or LiteSpeed hosts (OVHcloud, o2switch, Ionos, Hostinger). Place it before the CMS rewrite rules and test an underscore URL with curl before moving on.

WordPress

Versions WordPress 6.4 and later.

WordPress generates hyphens on its own: the title sanitizing function replaces spaces with hyphens, converts to lowercase and strips accents on save. It does, however, keep underscores typed by hand in the slug field.

  1. Settings > Permalinks: choose “Post name” (/%postname%/) or a structure that includes the category.
  2. In the editor, in the post panel, check the suggested slug before publishing for the first time.
  3. To fix an existing slug, edit it in the editor. WordPress automatically redirects the old slug of posts and non-hierarchical content types, but not that of pages: add the redirect with the Redirection plugin, Rank Math's Redirections module or the Yoast SEO Premium redirect manager.

Shopify

Versions Shopify admin, all plans, November 2026.

Shopify generates the URL handle from the title, with hyphens. To change it: on the product, collection or page, “Search engine listing” section, edit button, “URL handle” field. Leave checked the box that creates a redirect from the old URL. Existing redirects are managed in Content > Menus, via the “View URL redirects” button, with CSV import for batches.

PrestaShop

Versions PrestaShop 8 and 9.

The “Friendly URL” field (SEO tab of the product or category page) is filled in automatically with hyphens from the name. In Shop Parameters > Traffic & SEO, check that friendly URLs are enabled. PrestaShop product URLs contain a numeric ID: with the redirect-to-canonical-URL option set to 301 on that same screen, the old form of the slug should in principle redirect to the new one. Check it with curl after every change.

Drupal

Versions Drupal 10 and 11, Pathauto and Redirect modules.

With the Pathauto module, the separator is set in Configuration > Search and metadata > URL aliases > Settings (/admin/config/search/path/settings), “Separator” field: keep the hyphen, and tick the lowercase option. Then regenerate aliases in bulk from the dedicated tab, and enable the Redirect module to create 301s for old aliases automatically.

Laravel

Versions Laravel 11 to 13.

Str::slug() uses the hyphen by default and also converts underscores to hyphens. Pass the language for correct transliteration:

use Illuminate\Support\Str;

$slug = Str::slug('Thé vert : bienfaits & préparation', '-', 'fr');
// the-vert-bienfaits-preparation

If you change existing slugs, keep the old ones in a table and redirect:

Route::get('/guides/{slug}', function (string $slug) {
    $guide = Guide::where('slug', $slug)->first();

    if ($guide) {
        return view('guides.show', ['guide' => $guide]);
    }

    $ancienSlug = GuideSlugHistory::where('slug', $slug)->firstOrFail();

    return redirect()->route('guides.show', $ancienSlug->guide->slug, 301);
})->name('guides.show');

Next.js

Versions Next.js 15 and 16.

Generate slugs when the content is created (in the headless CMS or the import script), not at render time:

export function slugify(title: string): string {
  return title
    .normalize('NFD')
    .replace(/[̀-ͯ]/g, '')
    .toLowerCase()
    .replace(/[^a-z0-9]+/g, '-')
    .replace(/^-+|-+$/g, '');
}

For old URLs, declare the redirects in next.config.js. permanent: true returns a 308, which Google treats as a 301:

module.exports = {
  async redirects() {
    return [
      { source: '/guides/choisir_the_vert', destination: '/guides/choisir-the-vert', permanent: true },
    ];
  },
};

Common mistakes

  • Mass-changing the URLs of an established site for this reason alone: the gain is small and the risk of losing real traffic during reconsolidation is genuine.
  • Redirecting without updating internal links: every internal click goes through a redirect. See fix links to redirects or non-canonical URLs (opens in a new tab).
  • Applying a generic rule to files: images and PDFs with underscores become 404s.
  • Letting both versions return a 200: /mon_article/ and /mon-article/ become duplicates.
  • Joined-up words (/cartecadeau/): as hard to read as an underscore.
  • Spaces in file names uploaded to the CMS: they become %20 in the media URL. Rename files before uploading.
  • Redirect chain: the old URL redirects to a hyphenated version, which in turn redirects to the version with a trailing slash. Aim for a single hop, see fix redirect chains (opens in a new tab).

Frequently asked questions

Hyphen or underscore in a URL: which is better for SEO?

The hyphen. Google explicitly recommends separating the words in a URL with hyphens rather than underscores, and not running words together. The hyphen makes each term readable for search engines and visitors, including when the link is underlined. The effect on rankings remains small: apply the rule to all new URLs without necessarily changing the old ones.

Should you change old URLs that contain underscores?

Only if the gain outweighs the risk. A page with little visibility and no external links can change its slug with a 301 redirect and updated internal links. A page that gets traffic or backlinks rarely benefits from changing for this reason alone: keep it, or take advantage of a planned redesign to fix everything with a complete redirect plan.

Does WordPress automatically put hyphens in URLs?

Yes. WordPress builds the slug from the title by replacing spaces with hyphens, converting to lowercase and stripping accents. However, it keeps underscores typed by hand in the slug field. It redirects the old slug of an edited post, but not that of a page: for pages, add the redirect with a dedicated plugin.

Are accented characters allowed in a URL?

Technically yes: Google accepts non-ASCII characters, provided they are UTF-8 encoded in links. In practice, an accented slug often shows up as unreadable sequences such as %C3%A9 when it is copied or shared. For a French-language site, the safest convention remains a lowercase slug without accents, with hyphens between words.

Updated on

Topic checklist (PDF)

And now?

In the “Architecture and navigation” topic

  1. Organize pages by topic and hierarchy
  2. Create pillar pages and supporting content
  3. Limit the click depth of strategic pages (three clicks if possible)
  4. Detect orphan pages
  5. Optimize menus and submenus
  6. Implement breadcrumbs
  7. Optimize footer links
  8. Use crawlable HTML links
  9. Create short, stable and descriptive URLs
  10. Separate words with hyphens
  11. Standardize letter case and trailing slashes
  12. Control URL parameters
  13. Control pagination and infinite scroll
  14. Control filters and facets
  15. Avoid infinite URL spaces
  16. Avoid categories that add no value
  17. Check links to commercial pages