Google recognizes an <image>
tag for XML sitemaps (http://support.google.com/webmasters/bin/answer.py?hl=en&answer=178636), and I would like to include an image attribute into my sitemaps.
So, something like this is needed to get the cover_image and then loaded into the xml file:
for article in articles:
print article.cover_image
I'd also need article.title
loaded too for the <image:title>
tag.
I've Googled and searched Stack Overflow for an example, but I surprisingly couldn't find any, so help appreciated.
My files so far:
## sitemaps.py ##
from django.contrib.sitemaps import Sitemap
from myproject.article.models import Article
class ArticleSitemap(Sitemap):
priority = 1.0
def items(self):
return Article.objects.order_by('-id').order_by('-pub_date')
def lastmod(self, obj):
return obj.pub_date
## urls.py ##
from myproject.sitemaps import ArticleSitemap
sitemaps = {
"article": ArticleSitemap
}
urlpatterns += patterns ('',
(r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps})