I have a website containing dynamic pages for Content which is added and removed periodically. Along with that the website also has static pages that always exist like /, /about, /how-it-works etc. I have configured my sitemaps.py file to load all the dynamic content pages in the sitemap.
sitemap.xml
...
<url>
<loc>
https://www.mywebsite.com/record?type=poem&id=165
</loc>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
...
sitemaps.py
from django.contrib.sitemaps import Sitemap
from website.models import Content
class MySitemap(Sitemap):
changefreq = "weekly"
priority = 0.5
def items(self):
return Content.objects.all()
models.py
class Content(models.Model):
content_type = models.CharField(max_length=255)
...
def get_absolute_url(self):
return '/record?type=' + self.content_type + '&id=' + str(self.id)
How do I add those static pages (/, /about etc) in my sitemap? Thanks!