将 WWW 添加到站点地图 Django
Prepend WWW to sitemap Django
我的网址没有 WWW,如何添加?
<url>
<loc>https://website.com/t/483/</loc>
<changefreq>daily</changefreq>
</url>
我用的是Django sitemaps.
因为我在我所有的网站上强制使用 www
我的设置里有以下内容,py
PREPEND_WWW = True
SITE_ID = 1
在我的 urls.py
from home.sitemaps import TitleSitemap
sitemaps = {
'titles': TitleSitemap,
}
我有一个 sitemaps.py
from django.contrib.sitemaps import Sitemap
from title.models import Title
class TitleSitemap(Sitemap):
changefreq = 'daily'
protocol = 'https'
def items(self):
return Title.objects.filter(error_code__isnull=True)
我已经能够通过更改管理页面中的域名值来解决这个问题。所以,如果你有
域名: example.com
替换为:
域名: www.example.com
我的网址没有 WWW,如何添加?
<url>
<loc>https://website.com/t/483/</loc>
<changefreq>daily</changefreq>
</url>
我用的是Django sitemaps.
因为我在我所有的网站上强制使用 www
我的设置里有以下内容,py
PREPEND_WWW = True
SITE_ID = 1
在我的 urls.py
from home.sitemaps import TitleSitemap
sitemaps = {
'titles': TitleSitemap,
}
我有一个 sitemaps.py
from django.contrib.sitemaps import Sitemap
from title.models import Title
class TitleSitemap(Sitemap):
changefreq = 'daily'
protocol = 'https'
def items(self):
return Title.objects.filter(error_code__isnull=True)
我已经能够通过更改管理页面中的域名值来解决这个问题。所以,如果你有
域名: example.com
替换为:
域名: www.example.com