也许我不明白站点地图的目的,或者也许我不明白如何使用站点地图。现在,我的站点地图包括所有“动态”创建的页面,例如博客文章。但是如何添加“静态”页面,例如我的索引和联系页面?或者这些视图不应该出现在站点地图中吗?我认为所有页面都应该在站点地图上。例如,我将如何包含这样的视图
(r'^contact/', include('contact-recaptcha.urls')),
如果没有查询集?
以供参考:http://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/ http://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/
提前致谢!
另一个更简单的选择:
from django.core.urlresolvers import reverse
from django.contrib.sitemaps import Sitemap
class ViewSitemap(Sitemap):
"""Reverse 'static' views for XML sitemap."""
def items(self):
# Return list of url names for views to include in sitemap
return ['homepage', 'news_article_list', 'contact_page']
def location(self, item):
return reverse(item)
sitemaps = {'views': ViewSitemap}
我故意省略了lastmod
and changefreq
,因为指定不正确/假设的数据比不包含它更糟糕。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)