1
定期的に追加または削除されるコンテンツ用の動的ページが含まれています。それに加えて、ウェブサイトには、/、/ about、/ how-it-worksなどのように常に存在する静的ページもあります。 sitemaps内のすべての動的コンテンツページを読み込むようにsitemaps.pyファイルを設定しました。Djangoのサイトマップ静的ページ
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)
どのように私はカントーを追加します私のサイトマップの静的なページ(/、/ aboutなど)? ありがとう!