Lee Willis

Adding Post Thumbnails To Your Sitemap

| 20 Comments

Google recently blogged about Adding Images to your Sitemaps. When I read this my thoughts jumped straight to a friend’s site that is image-orientated, and could really benefit from this. His site uses WordPress’ post thumbnails to store an image against each post, and I wanted to get those images into his sitemap.

His site already uses the great Google XML Sitemaps plugin to auto-generate an XML sitemap, so I thought I’d have a go at extending it to support post thumbnails.

The resulting XML looks a little like this:

<url>
  <loc>http://test.leewillis.co.uk/hello-world/</loc>
  <image:image>
    <image:loc>http://test.leewillis.co.uk/wp-content/uploads/test.jpg</image:loc>
    <image:title>Hello world!</image:title>
    <image:license>http://test.leewillis.co.uk/license/</image:license>
  </image:image>
  <lastmod>2010-04-14T21:15:15+00:00</lastmod>
  <changefreq>monthly</changefreq>
  <priority>1.0</priority>
</url>

Some notes on the above. The image title is set the same as the post’s title – which I figure should be a reasonable result, from a user and SEO point of view. The license URL is configurable (One per site).

I’ve submitted the code to the plugin author to hopefully get included, but if you can’t wait, there’s a patch file available here – just apply it with the “patch” utility.

20 Comments

Leave a Reply

Required fields are marked *.