How to Convert WordPress Tags from Underscores to Dashes for Better SEO

Convert WordPress Tags from Underscores to Dashes for Better SEO: Are your WordPress tag URLs using underscores, like /tag/keyword_tag? If so, it could be harming your search engine optimization (SEO). Google and most search engines do not treat underscores as word separators. As a result, keyword_tag is interpreted as a single word — keywordtag — not two distinct keywords.

Replacing underscores with dashes improves keyword visibility and creates cleaner, more SEO-friendly URLs. This guide shows you how to update your tags directly in the database using phpMyAdmin, plus how to set up redirects to preserve your traffic and rankings.

Why Use Dashes Instead of Underscores?

  • Dashes are interpreted by Google as space separators (e.g., keyword-phrase = "keyword phrase")
  • Underscores are not separators and merge words together (e.g., keyword_phrase = "keywordphrase")
  • Using dashes improves readability and helps your tags rank more accurately

Step-by-Step: Convert Tag Underscores to Dashes in WordPress

  1. Back up your WordPress database — always do this before making direct changes.
  2. Log in to your hosting control panel and open phpMyAdmin.
  3. Select your WordPress database from the sidebar (look for the one your site uses).
  4. Click the SQL tab to open the SQL query box.
  5. Paste and run the following SQL queries:
    
    UPDATE wp_terms SET slug = REPLACE(slug, '_', '-');
    UPDATE wp_terms SET name = REPLACE(name, '_', ' ');
        

    Note: If your database tables use a custom prefix (e.g., mywp_terms), update the table name accordingly.

  6. Click Go to execute. Your tags will now use dashes instead of underscores.

Redirecting Old Tag URLs (Underscores to Dashes)

To avoid broken links and preserve SEO value, redirect old tag URLs to the new format using your .htaccess file:


RewriteEngine On
RewriteCond %{REQUEST_URI} ^/tag/([a-zA-Z0-9]+)_(.*)$
RewriteRule ^tag/(.*)_(.*)$ /tag/%1-%2 [R=301,L]

This simple rule handles one underscore. For multiple underscores or complex tag structures, you may need a more advanced pattern — just ask if you'd like help with that.

After the Update: Final Steps

  • Visit Settings → Permalinks in your WP admin and click “Save Changes” to flush rewrite rules.
  • Check your site for broken tag links or 404s.
  • Test a few tag URLs to confirm they now use hyphens instead of underscores.

Final Thoughts

Switching from underscores to dashes in WordPress tags is a small but meaningful SEO improvement. Cleaner URLs, better keyword recognition, and improved link indexing are all benefits you’ll gain. Just be sure to back up your data first, update slugs correctly, and set up proper redirects to avoid SEO damage.

If you’re migrating from an older plugin like Ultimate Tag Warrior or just modernizing your site’s tagging structure, this update is essential.