Image Sitemap XML: A Complete Guide to Getting Your Images Indexed by Google

You've got pages in the index and a pile of images that Google has never seen. Common problem. Googlebot gives up on pictures buried in JavaScript, carousels and paginated galleries, and waiting won't change its mind. Hand it a list instead. That's all an image sitemap is. Set aside an afternoon. Most of it goes on checking the file, not writing it.
What follows: the format, a working example, a small generator, the Search Console steps, the WordPress shortcut, and the mistakes I'd look for first. I've added a section on telling whether the sitemap did anything, because people tend to skip that bit.
What is an image sitemap?
It's a plain XML file. For every page URL, you list the images that show up on that page, and Googlebot reads the whole thing. Pictures it would have skipped now get found.
Will it get everything indexed? No. You're improving the odds, that's the whole deal. Google still decides what's worth keeping, so a weak or duplicate image can sit in your sitemap for good and never appear.
Older guides tell you to add a title, caption, location and license for every image. Google's documentation dropped those tags, so my example below leaves them out. Two tags matter now: the image wrapper and the image location.
Why bother with one?
Why do it anyway? Because a click in Google Images takes people to your page, not to the raw image file. Those are real visits.
New images get found sooner. A redesign that wipes out your old markup no longer hides them. Indexed images can also surface in visual search and in AI answers that include pictures, and how images appear in AI search results goes deeper on that.
There's a quieter benefit as well. Keep a list of your important images and you start noticing the ones that are missing, broken or duplicated. Don't be surprised if a few dead image URLs turn up the first time you build one.
What does an image sitemap look like?
One entry looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>https://melotools.com/blog/jpeg-xl-lossless-vs-lossy</loc>
<lastmod>2026-10-23</lastmod>
<image:image>
<image:loc>https://melotools.com/images/jpeg-xl-comparison.webp</image:loc>
</image:image>
<image:image>
<image:loc>https://melotools.com/images/jpeg-xl-quality-chart.webp</image:loc>
</image:image>
</url>
</urlset>
A single <url> block can hold up to 1,000 image entries, and inside each one <image:loc> is the only required tag. Keep the namespace line at the top, since it's what makes the image tags legal. There's no changefreq or priority here either, because Google ignores both these days.
<loc> is the page and <image:loc> is the picture. Swap them by mistake and you get a file that validates fine and does nothing.
How do I build one?
Which images should I list?
Which pictures belong in the file? The ones you'd want a stranger to stumble on: hero shots, product photos, featured images, infographics, logos. Tiled backgrounds and spacer GIFs stay out, because nobody searches for those.
Decorative icons can go too. An image that only makes a button look nice doesn't belong in a search index.
Here's my test. Would this picture make sense as a search result by itself? Then list it.
How do I generate the file?
On a tiny site you can type the file out by hand. Bigger sites need a generator. In Next.js, a route handler at app/sitemap.xml/route.ts can build it whenever someone requests it.
This Node snippet does the job:
const escapeXml = (s) =>
s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")
.replace(/"/g, """).replace(/'/g, "'");
const imageSitemapEntry = (pageUrl, images) => {
const imageXml = images.map(img => `
<image:image>
<image:loc>${escapeXml(img.url)}</image:loc>
</image:image>`).join("");
return `
<url>
<loc>${escapeXml(pageUrl)}</loc>
<lastmod>${new Date().toISOString().split("T")[0]}</lastmod>${imageXml}
</url>`;
};
Pass in a page URL plus its images, taken from your database or markdown files. Wrap everything in the <urlset> header and send it back with a content type of application/xml.
Two details deserve attention. Escape every URL, since an ampersand in a query string will break the file. And use real modified dates where you can, because a lastmod that changes on every build teaches Google to ignore it.
How do I check the file before submitting?
Don't skip validation. It's easy to forget a namespace, leave an ampersand raw or close the wrong tag, and one slip is enough to break the file. Any XML validator will flag it. Search Console flags it as well, though only after you've submitted.
Try opening it in a browser. If you see a parse error where a tree of tags should be, stop and fix that.
Then take five of the image URLs and load each one in its own tab. Two minutes, and you'll catch the silly mistakes.
How do I submit it?
Submitting happens in Search Console. Choose your property, click Sitemaps in the sidebar, paste in the sitemap address (say, https://melotools.com/sitemap.xml) and hit Submit. A few days on, go back and read the status and the discovered-pages count.
A second file isn't compulsory. Image entries can sit inside your regular sitemap, and that works fine. I lean towards a separate file on larger sites, mostly so the page list stays readable.
Add a Sitemap: line to robots.txt as well, and other crawlers can find the file too.
What about WordPress?
WordPress hands this to a plugin. Yoast SEO, Rank Math, All in One SEO and Google XML Sitemaps can each produce image sitemaps; switch the option on, then submit whatever URL the plugin shows.
Afterwards, open what it produced. Some plugins list every file in the media library, even images no page uses, and if yours does you should trim the list. Our WordPress image optimization guide covers the setup around it, from formats to lazy loading.
What habits keep it healthy?
A few rules of thumb. Point at the canonical image instead of a thumbnail, unless the thumbnail is what you're after. Write absolute URLs. One file is capped at 50 MB and 50,000 URLs; beyond that, split it and tie the pieces together with a sitemap index. And resubmit when images change, never on a schedule.
Keep robots.txt out of the way too. Disallow the folder your images live in and the sitemap leads Google to a locked door.
After a redesign, open the file again. A new theme or CDN path can quietly break every URL in it.
What goes wrong most often?
Dead links top the list. Every <image:loc> should return a 200, so crawl the file and clear out the 404s before Google finds them. Relative paths come second; write the full https:// address.
The page around the image counts too. There's no alt text field in the sitemap, but Google reads the alt text and the nearby copy regardless, and a lone picture on a nearly empty page gives it little to go on. For writing alt text, see the alt text and SEO guide; the image SEO checklist covers the rest of the page.
As for resubmitting the same file over and over, it achieves nothing.
Here's one more trap. If your images sit on a CDN domain you haven't verified, they may never appear. Google wants both domains verified in Search Console, so confirm that before you start wondering what went wrong.
How do I know it worked?
Wait a couple of weeks, then look. Search Console's page indexing report shows how Google treats your pages, and a site:yourdomain.com search in Google Images gives a rough view of what's indexed, though the count is only approximate.
Nothing will jump overnight. Images get indexed slowly, and a sitemap only helps discovery. A month with no change usually points at image quality or access, not the file. To see what Google looks for, read how Google indexes images and then run the checks in the technical SEO guide for images.
What if my images still don't show up?
Start with the dull stuff. Is the image URL blocked in robots.txt? Does it load with a 200 when you're logged out? Is the page that holds it indexed? An image on an unindexed page rarely gets anywhere alone.
After that, judge the image itself. Tiny files, near-duplicates and stock photos found on a thousand other sites give Google little reason to keep yours. A chart nobody else has, or a clear product shot, has better odds than a generic banner.
Last, wait. A few weeks should pass before you change anything, since tinkering with a file Google hasn't processed yet only muddies things.
FAQ
Does an image sitemap guarantee my images get indexed?
No. Google takes your list and then makes up its own mind, which means low quality images, duplicates and anything against policy can still be dropped. The sitemap gets images found, nothing more. A place in the results isn't part of the deal.
Can I list images hosted on another domain?
Yes. Unlike a normal sitemap, an image sitemap accepts pictures on a CDN or other outside storage. You need to verify both domains in Search Console, and robots.txt must leave the images alone. Miss either step and nothing shows up.
How often should I update it?
Whenever images are added or removed. If you publish often, generate the file automatically so every new post goes straight in. Resubmitting an unchanged file achieves nothing, so go back to Search Console only after a big structural change to your site.
Does it help my normal web rankings?
Only indirectly. Better image indexing can bring Google Images traffic, and well-prepared images help page speed. The sitemap on its own won't lift anything, so your text pages shouldn't be expected to move just because you submitted one. Treat it as a discovery tool.
Do I still need title, caption and license tags?
No. Google's documentation dropped the title, caption, geo location and license tags, leaving the image wrapper and the image location as the only ones that matter. Older tutorials still show the rest. Filling them in for every image is wasted effort, so keep the file lean.
How many images can one page entry hold?
A single page URL takes up to 1,000 image entries. Few pages come close, so only huge galleries need to worry. If you hit the cap, list the images that matter most, since a gallery of a thousand near-identical photos won't all earn a place in the index.
Related Guides
JPEG XL Lossless vs Lossy: Which Encoding Mode Should You Use?
JPEG XL lossless vs lossy explained: how the two encoding modes differ, when to use each, and what the file size numbers mean for web performance.
How to Resize Images Without Losing Quality: A Complete 2026 Guide
Learn how to resize images without losing quality. Step-by-step help with browser tools, formats, srcset and the common mistakes that blur your photos.
JPEG XL vs AVIF: The Next Image Format Battle Explained
JPEG XL vs AVIF compared: compression efficiency, browser support in 2026, encode speed, and which next-gen image format to use for your web project today.
How to Make Images Load Faster on Your Website
Images slow down most websites. This guide explains how to make images load faster in 7 steps using free tools, no coding or technical knowledge needed.
Image SEO Checklist for Developers: Alt Text, Schema, Format and Speed
The complete image SEO checklist for developers — alt text rules, ImageObject schema, image sitemaps, file naming, and Core Web Vitals fixes with code.
Responsive Images Explained: srcset, sizes and the picture Element
Master responsive images with srcset, sizes, and the picture element. Includes WebP fallback patterns, Next.js Image component setup, and the exact code to implement today.