• Skip to main content
  • Skip to primary sidebar
  • Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

remove tag base in wordpress not easy as category base

July 19, 2025 By Raju Ginne

subject: remove tag base in wordpress

Problem:  we can strip category base with seo plugins like yoast and rank math and period in category base but tag base not working.

if we put ./ in tag base then cateogory base not working

 

to remove the /tag/ base from tag URLs in WordPress (e.g., change /tag/example/ to /example/), you have several options, but it’s important to note that removing the tag base is not officially supported by WordPress and can introduce conflicts, particularly if a tag slug matches a page or post slug. Here are the most common methods:

1. Permalink Settings (Core Method)

  • Go to Settings > Permalinks in your WordPress dashboard.

  • Under the “Optional” section, find the Tag base field.

  • Enter a single dot (.) in the Tag base field.

  • Click Save Changes.

This instructs WordPress to remove the /tag/ base from tag archive URLs. However, this method may not work with all hosting setups, particularly on localhost environments, and might cause issues with pagination or conflict with post/page slugs. Also, some versions of WordPress have reportedly had bugs or broken pagination when using this method, especially after version 4.6.

2. Using a Plugin
While your query focuses on removing the base without a plugin, currently there is no widely supported plugin that reliably strips only the tag base (most cover categories). Plugins like “Remove Category URL” only work for categories, not tags. Some SEO plugins (e.g., Yoast, Rank Math, AIOSEO) provide settings to strip the category base but do not offer this for tags, as confirmed in user discussions and documentation.

3. Custom Code (Advanced/Not Officially Supported)

  • You may attempt to rewrite tag URLs via custom code in your theme’s functions.php using the generate_rewrite_rules filter, combined with use of term_link and custom rewrite rules.

  • This approach requires advanced knowledge of WordPress rewrites and is not guaranteed to be stable, especially across WordPress updates.

Known Limitations

  • Slug conflicts: Removing the tag base can result in URL conflicts between tags and pages/posts with the same name.

  • Broken functionality: Methods that work for category bases (dot method, plugins, SEO plugin settings) do not properly extend to tag bases in recent WordPress versions.

  • SEO impact: Frequent URL changes can harm SEO if not correctly redirected.

Summary Table

Method Works for Tags Stable Notes
Permalinks “.” method Sometimes No May break pagination/archives; not reliable
Plugins Not usually N/A “Remove Category URL” does not support tags
Custom Code Possible Risky Needs expertise, may break on updates; not official

Recommendation:
While you can attempt the dot method in permalinks for tags, it is not guaranteed to work and is not officially supported. For most use cases, it’s best to keep the tag base or consider alternative link structures to avoid potential website issues.

If you absolutely require tag base removal, you must be prepared to maintain custom rewrite rules and thoroughly test for conflicts and errors. Most users compromise by accepting the default /tag/ base, as category base removal is much better supported.

For categories, not tags: Plugins like Yoast, Rank Math, and AIOSEO can reliably remove the category base but do not support removing the tag base.

Table of Contents

Toggle
  • Why ./ Breaks Category Base for Tags
  • Solutions for Removing the Tag Base
  • Why SEO Plugins Work for Categories but Not Tags

Why ./ Breaks Category Base for Tags

 

WordPress’s permalink structure relies on a precise set of rewrite rules. When you set the category base or tag base to ./, you’re essentially telling WordPress to treat those archives as if they’re directly at the root of your domain.

The problem arises from how WordPress resolves these “root-level” permalinks. If you set both category and tag bases to ./, WordPress struggles to distinguish between yoursite.com/my-category/ and yoursite.com/my-tag/ if a category and a tag happen to have the same slug. This can lead to conflicts, 404 errors, or unexpected redirects, as you’re experiencing with your category base.

 

Solutions for Removing the Tag Base

 

Given your constraint of not breaking the category base, here are the most effective methods:

1. Use a Dedicated Plugin (Recommended for ease of use):

This is often the simplest and most robust solution, as these plugins are designed to handle the complex rewrite rules and potential conflicts.

  • WP No Tag Base: This plugin is specifically designed to remove the /tag/ base from your URLs. It’s often highly effective and handles 301 redirects for old URLs, which is crucial for SEO. Search for “WP No Tag Base” in your WordPress plugin repository.
  • Custom Permalinks: Plugins like “Custom Permalinks” or “All in One SEO (AIOSEO)” (which also has a “Remove Category Base Prefix” option, though you’re looking for tags) offer more granular control over individual permalinks, including those for tags. While primarily for categories, some SEO plugins might have hidden settings or custom code options for tags.

2. Manual Method with functions.php (More advanced, be careful):

If you’re comfortable with code, you can add rewrite rules to your theme’s functions.php file. This method requires careful implementation and testing.

Important Considerations before using this method:

  • Backup your site: Always back up your functions.php file and your entire WordPress installation before making direct code changes.
  • Child Theme: Use a child theme to add this code. If you add it directly to your parent theme, your changes will be overwritten when the theme updates.
  • Permalink Flush: After adding or modifying rewrite rules, you must go to Settings > Permalinks in your WordPress admin and simply click “Save Changes” (without making any actual changes to the settings). This flushes the rewrite rules and activates your new settings.

Here’s a conceptual example of how you might attempt this (this is a simplified example and might require adjustments based on your specific WordPress setup and other plugins):

PHP

function custom_tag_rewrite_rules() {
    global $wp_rewrite;
    $wp_rewrite->add_rewrite_tag('%tagname%', '([^/]+)', 'tag=');
    $wp_rewrite->add_permastruct('post_tag', '%tagname%', false); // Make sure 'false' is used for no base

    // Optional: Add a redirect for old /tag/ URLs
    add_action('template_redirect', 'redirect_old_tag_urls');
}
add_action('init', 'custom_tag_rewrite_rules', 999); // Higher priority to ensure it runs late

function redirect_old_tag_urls() {
    if (is_tag() && strpos($_SERVER['REQUEST_URI'], '/tag/') !== false) {
        $tag = get_queried_object();
        if ($tag && $tag->slug) {
            wp_redirect(site_url('/' . $tag->slug . '/'), 301);
            exit();
        }
    }
}

Explanation of the conceptual code:

  • add_rewrite_tag('%tagname%', '([^/]+)', 'tag=');: This defines a new rewrite tag %tagname% that captures anything between slashes as the tag slug.
  • add_permastruct('post_tag', '%tagname%', false);: This tells WordPress to use the %tagname% directly for tags, effectively removing the /tag/ base. The false parameter indicates that no base should be prepended.
  • redirect_old_tag_urls(): This function is crucial for SEO. If someone visits an old /tag/my-tag/ URL, it will redirect them (301 permanent redirect) to my-tag/.

Important Note for Manual Method: Implementing custom rewrite rules can be complex and may conflict with other plugins or future WordPress updates. It’s generally recommended for experienced developers.

 

Why SEO Plugins Work for Categories but Not Tags

 

SEO plugins like Yoast and Rank Math usually have a specific setting for stripping the category base because it’s a very common request and they have built-in logic to handle the associated rewrite rules and potential conflicts (like redirecting old URLs).

However, the option to strip the tag base is less common or might be implemented differently. This is partly due to the potential for more ambiguity with tags, especially if you have a page or post with the same slug as a tag, leading to URL conflicts that are harder to resolve automatically.

https://wordpress.com/plugins/wp-no-base-permalink

https://wordpress.org/plugins/wp-no-tag-base/

About Raju Ginne

AMFI Registered mutual fund distributor based in Hyderabad. you may contact me for mutual funds SIP investments Whatsapp: 9966367675.
nism certified research analyst

Primary Sidebar

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy