Optimizing categories and tags is one of those SEO topics you cannot really avoid. If the strategy is good, category and tag archives can bring in a lot of search traffic. If the strategy is poor, those same archives can create duplicate or low-quality pages and hurt SEO instead.
The nature of WordPress categories and tags
Categories are hierarchical. In practice, we usually use them to organize site structure, build navigation, and define the main sections of the site. When publishing a post, we normally assign it to at least one category.
Tags are not hierarchical. They are flatter and more flexible, and we often use them to describe a post with keywords. Because tags are so free-form, it is easy to end up with tag archive pages that contain only one or two posts. Those thin archives are often low quality and should usually be excluded from indexing.
When tags should be excluded from search indexes and how to do it
If category and tag archives display full post content, then both category and tag archives should usually be excluded from indexing. Otherwise, those archive pages may be seen as duplicate pages that repeat the same content as the posts themselves.
If category or tag archives display excerpts instead of full content, category archives usually do not need to be excluded because each entry only shows a short part of the article. But a tag archive with only one or two posts is still a thin page, and search engines may either ignore it or treat it as low quality.
Automatically noindex tag archives with very little content
The following code automatically adds a noindex, follow robots tag to tag archives that contain fewer than four posts:
/**
* Automatically noindex tag archives with fewer than 4 posts.
*/
add_action( 'wp_head', function () {
if ( is_tag() ) {
global $wp_query;
if ( $wp_query->found_posts < 4 ) {
echo '<meta name="robots" content="noindex, follow">' . "n";
}
}
} );
Increase the number of posts shown on tag archives to improve page quality
On many sites, a tag archive does not contain a large number of posts. On our own site, most tag archives stay under twenty posts. To make sure the archive can show all of its posts on one page and become more useful, we increased the number of posts shown per page on tag archives.
The implementation looks like this:
/**
* Increase the number of posts shown on tag archives to avoid pagination when possible.
*/
add_action( 'pre_get_posts', function ( $query ) {
global $wp_the_query;
if ( ! is_admin() && $query === $wp_the_query && $query->is_tag() ) {
$query->set( 'posts_per_page', 20 );
}
return $query;
} );
Categories and tags should not duplicate each other semantically
If categories or tags contain identical words or close synonyms, search engines may treat those archives as duplicate pages. The cleanest solution is to merge overlapping terms and avoid creating that duplication in the first place.
As a rule, a smaller number of well-planned tags usually performs better for SEO than a huge collection of loosely managed tags.
These strategies have worked reasonably well on this site, but whether they fit your project depends on the site’s structure and overall SEO plan. If you use a different category and tag strategy for WordPress SEO, it is a good topic to discuss and compare.
