How to Stop Google from Indexing your WordPress Image Attachment Pages

serps

Stop Indexing WordPress Attachment Pages

Have you every actually checked how your website appears in SERPs? You might want to, especially if you are running WordPress. The reason is that when you upload an image and insert the normal way it creates a separate WordPress attachment page. And if you aren’t careful Google might actually start indexing these pages. You can see below in this picture that is what happened to me.

brand name in serps

You can see above that “raventools” and “google-authorship” are actually the names of two image attachment pages. Example, here is what the raventools link goes to: https://brianjackson.io/adding-keywords-to-raven-tools-ranking-in-bulk/raven-tools.

raven tools

You can see that page is simply the attachment page that is created due to the image upload. Why is this a bad thing? It’s bad because in SERPs you have things showing up that are named wrong. Also, visitors are now hitting pages that are completely blank which may in turn lead to a higher bounce rate.

There are a couple different ways to prevent Google from indexing your WP attachment pages.

Option 1 (preferred method)

The easiest way to fix this is to redirect the WordPress attachment pages to the original page/post. In this example I will show you how to do this using the Yoast SEO plugin. (there is also a similar setting in the All in One SEO plugin)

Step 1

In WordPress click into SEO and then click on “Advanced”

yoast SEO advanced

Step 2

Click into the “Permalinks” tab.

yoast permalinks

Step 3

Then select the box “Redirect attachment URL’s to parent post URL.”

redirect attachment URLs to parent post

Step 4

Then click “Save Changes.”

save changes

So now my raventools attachment page here: https://brianjackson.io/adding-keywords-to-raven-tools-ranking-in-bulk/raven-tools is redirected to the post that the image is on: https://brianjackson.io/adding-keywords-to-raven-tools-ranking-in-bulk/

Option 2

Another way to prevent this from happening is to click into the image attachment page and mark it as no-index within the Yoast plugin.

no-index

Option 3

A third way to prevent this as Olaf mentioned below in the comments is that you could block all of your attachment pages from indexing within your robots.txt file. I prefer option 1 as it is quick and easy.

Option 4

If you don’t want to install or use Yoast, there is also a standalone WordPress plugin called Noindex Attachment Pages.

Now your SERP listings should look cleaner and your visitors won’t be hitting blank pages.

As always feel free to leave your comments below! Make sure to subscribe to my newsletter for more great SEO and WordPress tips.

GET MORE STUFF LIKE THIS

Marketing, WordPress, Blogging Tips, SEO and Reviews, once a week.

Thank you for subscribing.

Something went wrong.

38 thoughts on “How to Stop Google from Indexing your WordPress Image Attachment Pages

  1. Hi Brian,
    Please explain option 2 a bit more, how does it work? The attachment URL exists for every image and is not related to the fact that an image is linked to a post or not. Many themes require this option to build galleries and sliders. How about option 3 to use the robots.txt file and block the attachment URL for indexing? Anyway I use option 1 since year because it’s fix for something that Google is doing wrong.

    • Oops, ya that was my bad. You are correct, whether is it uploaded within the post or directly from the media library an attachment page is created regardless. I have updated the post above with 2 additional options (mentioned you). Obviously option 1 is the quickest and easiest way to fix this problem. Thanks for your comment and fixing my mistake!

      • Right this noindex option for media posts is an option I use too. You should use both WordPress SEO settings to get the job done. And for those using a different SEO tool this robots.txt entry should help:

        Disallow: /?attachment_id

        It’s not the best way to stop bots indexing them…

  2. Hey Brian thanks for this but I’m struggling to find a similar setting for Option 1 in All in one SEO? apart from no indexing media which is not what we want? Any pointers? cheers

  3. Why do you say visitors will be hitting blank pages? What about photography sites? There I guess you’d want the attachment pages to be found..

          • But there’s still nothing wrong with people finding your images on the attachment page! If they’re nicely styled this is a good way of presenting them to online searches.

          • True :) I guess I have never seen a nice one. Most don’t have any styles on them because themes don’t style attachment pages. But depending on how the theme is setup I could definitely see it possibly working, especially if you are running a photography site.

          • Brian, I most def have to agree with Avalonica here! for example, my client has very big blog where each attachment page (for images) have bunch of tags that are related to that perticular image (not tags for parent post) so each of that tags (very scientific) will be very good SEO boost actually ,,it’s great to have that pages man :)

          • I am happy to be proven wrong :) but nobody has shown me a good example of a tag page in SERPs before. You mind sharing a URL? From my experience tags don’t help your SEO at all.

            Unless your speaking of it from a usability standpoint? Are you hoping someone will land on it and click a tag?

  4. Did you just recently implement options 1 and 2? Because it might take a bit for them to drop out of SERPs. You shouldn’t have to do all of the options above for it to work. Although nice to have options :)

  5. Did you then keep the setting in option 1 as well? Because when I do that I am getting a warning from yoast just above the media section in post types: “As you are redirecting attachment URLs to parent post URLs, these settings will currently only have an effect on unattached media items!”

  6. This is very helpful as I have way too many images on my website. People usually just go to the individual image post and bounce off from there. Hope your first option will help reduce bounce rates. Thank you!

  7. Congratulation for this post, Brian; what is for you best option that avoid permalink images indexed in serp but allow index for google images?

    • Using the Yoast SEO “redirect attachment URL” option seems to be the best to avoid image permalink from being indexed and still allowing for images to be indexed. That is how I have my sites setup.

  8. Hi, Does this have a negative impact on SEO when turning off for sites who have a history of their pages indexed in search.

Leave a Comment

135 Shares
Tweet
Share
Share
Buffer