To keep images out of Google Images, add a rule for the Googlebot-Image user agent that disallows the folder or file. This stops that crawler fetching those images, but it does not hide them from people who have the direct link and it does not instantly remove images that are already indexed.
The rule
User-agent: Googlebot-Image
Disallow: /private-images/This blocks the Google Images crawler from that folder only. To block every image on the site, use Disallow: / under the same user agent, though that is rarely what a business wants.
Block one file type
User-agent: Googlebot-Image
Disallow: /*.gif$The pattern uses the wildcard rules explained in robots.txt wildcards.
Not sure if this is hurting your site?
Get the fixes that matter most, in priority order.
What this does not do
- It does not password-protect the files.
- It does not stop other crawlers unless you add rules for them.
- It does not remove images already in the index quickly. Use the removals tool or return an error status for urgent cases.
Be careful about blocking useful images
Images help pages rank for image search and help Google understand content. Blocking product or portfolio photos by accident can reduce visibility. If you want images found, follow image SEO best practices instead.
Test the rule
Write the rule with the robots.txt generator, then check a sample image URL in the robots.txt tester.
Frequently asked questions
Will blocking images hurt my page rankings?
It can reduce image search traffic and give Google less context about the page, so block only what you truly need to.
Can I allow one image inside a blocked folder?
Yes. Add a more specific Allow rule for that file.
Next steps
If you need to protect images properly, restrict access on the server. For a review, contact me here.
More in this series (robots.txt testing questions): start with Robots.txt Tester and AI Crawler Checker, then explore:
- How to Test Robots.txt in Google Search Console
- Robots.txt Returns 404 or 500: What Google Does and How to Fix It
- Robots.txt User-Agent Groups: Which Rules Does Googlebot Follow?
- Does Robots.txt Apply to Subdomains and HTTP vs HTTPS?
Request received
Thank you! Saad will contact you within the next 24 hours.
Keep an eye on your phone and inbox.
