WordPress SEO – Hide your automatically resized images from Google


So, you’ve got your website all ready to launch, you’ve done some SEO and now you’re finally ready to show it to the world.

You’ve even gone so far as to optimize your images for SEO – paying careful attention to the keywords you’ve used in the filename, ALT text and the text surrounding the image.

You’re thinking, this is definitely going to pay some dividends, because you know some of your images will show up in blended search results like this:


Blended Search Results

The problem

Google will index your images but they may not index the right versions.

WordPress resizes images every time you upload them

Screen Shot 2015-06-18 at 5.12.52 PM

So many files!

WordPress has a handy little feature called image resizing. When you upload an image to the Media Library, WordPress looks at what image sizes are defined in your theme. By default WordPress has 4 sizes – Thumbnail, Medium, Large and Full. Some themes have many more image sizes depending on how things are set up. It’s not uncommon for us to create upwards of 20 image sizes for a client’s website.

Since WordPress is resizing these images each time you upload them, it creates a lot of extra clutter in your uploads directory – you end up with the original image and 3 or more additional copies.

Google is looking at all of these files

Since Google doesn’t know what’s an original and what’s been resized, it scans all of the images.

However in search results Google only shows the image that it thinks is the most important match for the user’s search query.

This means that if one of your images shows up in search results, the thumbnail version might be the version that shows up. But you want the original, high-res image to show up instead, right?

The Solution: Block Google from indexing your resized images so it is forced to index the originals

This uses Robots.txt wildcards. If you’re not familiar with Robots.txt, check out this awesome post that explains it all.

You’ll notice a pattern if you look at your uploads directory. Look at this one image for example:

  • crossbrowser.jpg
  • crossbrowser-351×185.jpg
  • crossbrowser-300×160.jpg
  • etc…

You want Google to index the original, but not the others. Open up your Robots.txt file and add:

User-agent: *
Disallow: /wp-content/uploads/*-*x*.png$
Disallow: /wp-content/uploads/*-*x*.jpg$
Disallow: /wp-content/uploads/*-*x*.jpeg$
Disallow: /wp-content/uploads/*-*x*.gif$

Each Disallow line is similar, but for different file types.

We’re telling google to ignore any PNG, JPG or GIF in the uploads directory that has a dash and an x with characters between them in the file name.

crossbrowser.jpg is indexed but crossbrowser351x185.jpg is ignored.

Just be sure when you’re uploading your images to avoid using a dash and then an x in the filename, and you’re safe.

You can test if Google will index specific files on your site using “Fetch as Google” under the “Crawl” tab of Google Webmaster Tools.

Bonus tip: Easily tell Google to ignore specific files in your uploads directory

Let’s say you have some images or files that you upload to WordPress that you just don’t want Google to index. Add this rule to Robots.txt and any file you upload that contains the word “ignore” will not be indexed by Google.

User-agent: *
Disallow: *ignore*


Share your Robots.txt SEO tips

These are just a couple of fun things you can do with Robots.txt.

Do you have a useful trick? Share it in the comments below for everyone to see.

font preload