Did you know that WordPress automatically generates multiple archive URLs for your website? While it may be useful in some cases, it may also hurt your SEO by generating duplicated content and unnecessary pages. Luckily, there is a quick and easy solution.
Why remove (or disable) archives in WordPress?
By default, WordPress will generate the following archives:
- Category archives
- Tag archives
- Author Archives
- Date archives
- Post format archives (if your WordPress theme supports it)
- Search archives (search results page)
Category archives
If you don’t have any categories on your website, all posts will automatically go to “Uncategorized” category and you will still have something like http://yourwebsite.com/category/uncategorized URL which is actually displaying the same content as your home or blog page. It just doesn’t make sense!
Of course, categories are sometimes crucial part of your WordPress websites and can be very useful. You can read more in this article about good SEO practice of using categories and tags on your WordPress website.
Tag archives
Sometimes people use a lot of “generic” tags which doesn’t make sense from a point of SEO, but can be rather useful to connect posts in a good way and display related content to a particular post. This means that you can keep using tags in the background and only avoid to display tag links and tag archive pages.
Author archives
If you have a lot of writers on your website you will probably want to use author archives. But, if you have only one author on the website then it just doesn’t make sense. Feel free to remove it and avoid duplicated content.
Date and other archives
Date archives and post formats archives are mostly unnecessary especially if you don’t publish your posts frequently. For search results archive, you will of course want to keep it for obvious reasons.
How to disable WordPress archives?
In the following snippet we are going to remove (disable) category, tag, date, and author archives but you may want to modify conditional statements inside the code to suit your exact needs. Just place this piece of code somewhere in your theme functions.php file:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/* Register template redirect action callback */ add_action('template_redirect', 'meks_remove_wp_archives'); /* Remove archives */ function meks_remove_wp_archives(){ //If we are on category or tag or date or author archive if( is_category() || is_tag() || is_date() || is_author() ) { global $wp_query; $wp_query->set_404(); //set to 404 not found page } } |
Bonus tip
In some cases, you may rather want to “noindex” your archives instead of removing it entirely. This means that your archives will be accessible but you will say to Google not to index those pages. Luckily, there is probably the best SEO WordPress plugin which will help you achieve this very easily.
[…] replaced, and all your changes will be gone. If you still want to go for it, you can find tutorials here and here with solutions. Proceed with caution and at your own […]
thanks for share amazing article 🙂
If Category as using Website menu, In condition disable categories Yes/No
I also use Yoast plugin for putting noindex, nofolow to date arhives pages. However what I found out is that Google still index those pages. So I decided to put them in robots.txt. Because of URL structure it was not easy but I made it and explain it in this post: https://www.vladopandzic.com/search-engine-optimization-seo/block-indexing-wordpress-date-arhives-pages/ .
I think its about 10th time when I come here and find solution I needed. Good job.
Thanks
Thank you – once again – for answering my questions!
The code does NOT remove the functionality, it simply returns a 404 error if those archive / categories are requested. However Google still indexes them. The comment from “Cameron” helps, but alas, this still does not turn off that functionality.
😉
Beautiful – thanks! Finally god rid of all that useless url-waste 🙂
I desperately needed this post. As a newbie blogger, I thought adding recent comments and post archives on the widget bar was cool. I recently discovered that it created duplicate content per google. For example, currently, my blog shows 14 Google indexed pages when I’ve only written about 5 posts. I hope I can remove the tag date and author archive successfully. I use Yoast plugin so I will try that route. Thanks for the post!
If only I saw this before I launched a WordPress site 🙂
Well it took me some time to de-index those archives as well as categories, tags and other rubbish generated by some plugin. But indeed it’s worth it, no more wasting crawl budger
A word of warning that this doesn’t send a 404 header, so if you have links to these pages they will still be indexed by search engines. Update your function to this:
function meks_remove_wp_archives(){
//If we are on category or tag or date or author archive
if( is_category() || is_tag() || is_date() || is_author() ) {
global $wp_query;
header(“HTTP/1.0 404 Not Found”);
$wp_query->set_404(); //set to 404 not found page
}
}
Hello Cameron,
is this function hiding or deleting the archives?
Hello
Because I really do not want those pages, that’s hat I’have done:
add_action(‘template_redirect’, ‘meks_remove_wp_archives’);
function meks_remove_wp_archives(){
if( is_category() || is_tag() || is_date() || is_author() ) {
wp_redirect( home_url(), 301 ); exit;
}
}
Thanks for this tip, Developer of Yoast WordPress SEO plugin has explained very well that it is always good idea to Disable unnecessary archives for better WordPress SEO.
WordPress users can use WordPress SEO plugin to disable the author archives or date based archive.
It’s my first time on your site but I already know that I will visit you often 🙂 Good job.
One question, will noindex attribute give me 100% certainty that google won’t register it as a duplicate content?
Thanks 🙂
In regard to your question, I guess only Google knows exact answer 🙂 but, yes, noindex should do as it says….
Cheers!
Just what I’ve been looking for. Thank you 🙂
As always I can find here useful tip. For me you are the WordPress masters! 🙂 I think its about 10th time when I come here and find solution I needed. Good job.
Hey Lester,
Thanks for your words! We’ll try to write more useful articles. Promise 🙂