WordPress creates attachment page for each uploaded media file. It comes in two forms.
Whatever, it is very thin content and invites Google Panda penalty.
So, we should always prefer keeping this kind of pages with meta robots noindex tag.
or, for non-attached media file.
One of my clients recently faced this problem because of her previous SEO’s mistake. They had forgotten to set noindex for attachment path after switching from All in One SEO to Yoast SEO plugin.
As a result, index counts increased rapidly and affected Site performance in the SERPs. In Google Analytics, the traffic graph was going downhill. As a webmaster, I can understand the frustration, when we lose traffic suddenly.
The blog for which I was working - originally, including post and pages, had roughly 300 pages. But index count 2900+
Screenshot: 04/Feb/2018, 08:59PM IST Before implementing the workaround.
indexing anything on the web is so easy in comparison to removing it. Sometimes search engine takes enough time to re-crawl the pages.
Newbies often do mistake in frustration by doing some stupid thing using robots.txt
User-agent:* Disallow: /blah-blah-blah/
More than good, it does harm. Even if you add a Disallow rule that doesn’t affect already indexed links.
Right way: We should prefer using meta robots only.
<meta name="robots" content="noindex,follow" />
Yoast SEO offers a one-click feature to set noindex for all media files.
Again… here some webmasters were doing mistakes by redirecting attachment to post.
Now, what’s about non-attached media file, that you never used in the post?
Is it suppose to be redirected? Never. Ref: Warning message. (Yoast SEO Version 6.3.1).
So, what’s the right way to use Yoast plugin for keeping noindex the attachment path?
Don’t set redirect.
Set noindex for Media
Well, this is great for the older version of Yoast SEO.
What’s new in Yoast 7.0?
Please do note, in Yoast SEO 7.0, redirect of attachment works little differently. For non-attached images, it will redirect to the image, instead of showing a thin web page.
So, in new version even if you keep redirected, it’s completely okay for non-attached media. In case you prefer avoiding redirect, you must manually set noindex.
Both are good options in latest version Yoast.
Back to topic.
Let me tell you what additionally I did for doing noindex attachment pages faster.
Now, I had little confusion in my mind…
- Should I really include attachment path in the XML sitemap or not?
Some folks say that Sitemap should contain only those paths which we want to index. Now, even more, the scary thing is Google can email you N numbers of pages contains noindex tag.
I skipped all these talks.
In short, this post says …
If you want to deindex your pages from Google, you’ve got the answer straight from the mouth of Google.
- Change to meta robots noindex
- Use the lastmod date to reflect the change
- Update your XML sitemap
I just implemented this technique, and my attachment pages started to noindex in Google.
Here’s the result: Index counts from 2907 to 428. Thankfully, this worked for me.
Screenshot: 11:20 PM 3/26/2018
Let’s jump into behind the scene - Technical stuff.
How to create XML sitemap that will help in noindexing attachment pages?
You don’t need to write XML code. I have a shortcut approach.
You just need to follow for a moment…
Install and activate Yoast 6.3.1, enable sitemap for attachment path.
Go to Title & Post > Set noindex for Media
Include Media in the Sitemap
Go to source code of
Copy the XML code to Notepad++ Application
Hint: For better visibility, highlight XML code by going to Language menu & choose XML.
Now, we need to tweak date/time of the last modified in this XML Sitemap. Press CTRL+H (Replace command).
- In find field, type
- Check Regular Expression
- In replace field, it’s time to trick with latest Timestamp.
So, finally press “Replace all” button.
Recap… this is what I did.
Once ready, upload to root directory where you can easily access. I had named it workaround.xml
Submit to Search console.
Wait for a week. You will notice, Google will start dropping attachment pages from the SERPs quickly.
- How to know if by mistake I am indexing Attachment pages?
Try searching on Google any post permalink, inurl:example.com/permalink/ if you see more than one URL, chances are you might be indexing Attachment pages which is bad for SEO.
- Why this method works?
lastmod at XML sitemap hints Googlebot for re-crawling the WordPress Attachment Pages. In presence of the meta robots noindex tag at Attachment pages, Google consider de-indexing it from the SERPs. It is a similar approach like we show last updated date for an old article instead of publishing date.
- Hey, I am facing difficulty in writing Timestamp in the UTC format?
No worries, just update a post and copy its last modified Timestamp from the XML sitemap source code.
I hope this helps. Let me know what do you think about this?
Thanks & Regards,