【发布时间】:2010-05-28 09:56:47
【问题描述】:
我的 Django 站点的自动站点地图会在 URL 上包含 www 和不包含它之间波动(我的目标是一直使用它)。这会导致谷歌无法正确索引我的页面,因此我正在尝试缩小导致此问题的原因。
我设置了PREPEND_WWW = True,并且我在站点框架中的站点记录设置为包括 www,例如它设置为www.example.com,而不是example.com。我正在使用 memcached,但页面应该在 48 小时后从缓存中过期,所以我不会想到会导致问题?
您可以在http://www.livingspaceltd.co.uk/sitemap.xml(刷新页面几次)查看问题。
我的站点地图设置相当平淡,所以我怀疑这是否是问题所在,但如果很明显我遗漏了这里的代码:
***urls.py***
sitemaps = {
'subpages': Subpages_Sitemap,
'standalone_pages': Standalone_Sitemap,
'categories': Categories_Sitemap,
}
urlpatterns = patterns('',
(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
...
***sitemaps.py***
# -*- coding: utf-8 -*-
from django_ls.livingspace.models import Page, Category, Standalone_Page, Subpage
from django.contrib.sitemaps import Sitemap
class Subpages_Sitemap(Sitemap):
changefreq = "monthly"
priority = 0.4
def items(self):
return Subpage.objects.filter(restricted_to__isnull=True)
class Standalone_Sitemap(Sitemap):
changefreq = "weekly"
priority = 1
def items(self):
return Standalone_Page.objects.all()
class Categories_Sitemap(Sitemap):
changefreq = "weekly"
priority = 0.7
def items(self):
return Category.objects.all()
【问题讨论】: