How to create an Image Sitemap from a visual studio project

🧭 How to Create an Image Sitemap in a Visual Studio Project
If you’re building a site in ASP.NET Core (or even older ASP.NET MVC) using Visual Studio, creating an image sitemap is a powerful way to improve the visibility of your site’s images in Google Image Search.
And yes — it's easier than you think (especially if you’re using my DevStack codebase where this is already baked in).
📸 Step 1: Identify Your Website's Images
Start by deciding which images you want to expose to search engines. These can include:
- Product images
- Gallery or portfolio images
- Blog post feature images
- Downloadable artwork or resources
If your images are dynamically loaded (e.g., from a database or CMS), you’ll need to programmatically reference them.
🌐 Step 2: Generate the Full Image URLs
Make sure each image has a publicly accessible URL, such as:
https://yourdomain.com/images/my-photo.jpg
If you're using Razor Pages, you might access them like:
Path.Combine(_webHostEnvironment.WebRootPath, "images", "filename.jpg");
🧾 Step 3: Create an XML Sitemap File
Create a standard-compliant XML file that lists your images along with optional metadata:
<?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://yourdomain.com/blog/post-1</loc>
<image:image>
<image:loc>https://yourdomain.com/images/post-1-feature.jpg</image:loc>
<image:caption>Cover photo for Post 1</image:caption>
<image:title>Post 1 Header Image</image:title>
</image:image>
</url>
</urlset>
💡 Pro tip: If your content is database-driven, you can dynamically generate this XML using Razor Pages, controllers, or a StringBuilder
.
💾 Step 4: Save It in Your Project
- Name your file something like
sitemap-images.xml
. - Save it in your
wwwroot
orpublic
directory (so it's web-accessible). - Test it by visiting
click here
in a browser.
📌 Step 5: Add to robots.txt
Update your robots.txt
file (also in wwwroot
) to include a reference:
Sitemap: https://yourdomain.com/sitemap-images.xml
This ensures bots like Googlebot know about your image sitemap even if you don't submit it manually.
🚀 Step 6: Submit via Google Search Console
Go to Google Search Console and submit the new sitemap under the "Sitemaps" section.
This boosts indexing and helps surface your visuals in Google Images.
🔧 Automate It (Or Don’t Bother — I Already Did)
If you're already deep in Visual Studio and .NET, why hand-roll this every time?
My DevStack codebase includes a dynamic sitemap generator, ready to go:
return Content(SitemapBuilder.GenerateImageSitemap(), "application/xml");
It pulls image data from your Downloads
, CMS, or any collection you wire in — complete with alt text, license info, and titles.
📈 Final Thoughts
Creating an image sitemap isn’t just about SEO — it's about telling Google what matters on your site.
If you’re working in Visual Studio and want to avoid yet another manual task, I’ve already done the hard part for you.
👉 Check out my DevStack codebase
📄 View my CV and tech portfolio
📬 Or reach out and let’s automate your next SEO win together.