I'm working on sitemap.xml
generation for Django + Wagtail project.
I implemented xml
generation for articles by overriding get_sitemap_urls
method. But the problem is that Wagtail sitemap generator doesn't "see" the blog tags urls (doesn't add them to the sitemap).
...
from taggit.models import TaggedItemBase
class BlogPageTag(TaggedItemBase):
content_object = ParentalKey(
'BlogInnerPage',
related_name='tagged_items',
on_delete=models.CASCADE,
)
class BlogInnerPage(Page):
icon = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=False,
on_delete=models.SET_NULL,
related_name='+'
)
...
post_date = models.DateTimeField(auto_now_add=True, null=True)
tags = ClusterTaggableManager(through=BlogPageTag, blank=False)
@property
def sidebar_tags(self):
blogs = BlogInnerPage.objects.live().all()
tags = {}
for post in blogs:
for tag in post.tags.all():
if tag.slug in tags:
tags[tag.slug]['count'] += 1
else:
tags[tag.slug] = {
'name': tag.name,
'count': 1
}
return sorted(tags.items())
...
def get_sitemap_urls(self):
return [
{
'location': self.full_url,
'lastmod': self.last_published_at,
'changefreq': 'weekly',
'priority': .8
}
]
I'm expecting to see the following result for tags:
<url>
<loc>https://example.com/?tag=design</loc>
<lastmod>2019-01-31T12:24:01+00:00</lastmod>
<priority>0.80</priority>
</url>
Here is what I've got for blog articles:
<url>
<loc>
http://example.com/trends-booming-todays-it-industry/
</loc>
<lastmod>2018-10-04</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>