I don't think this is actually possible, but is there any clean and tidy way to get paginated content working with Django sitemaps?
For example, my landing page has news on it, and there are no perm开发者_开发技巧alinks to news posts, the only way to use them is to paginate 5 at a time through them all.
Another part gets lists of items in various genres and other criteria.
If it isn't possible, what is the best way to handle it? To not provide urls to the sitemap for any of these? To get just the first page for paginated pages?
My best idea is that I should just give the landing page as an url, and not bother with the listing pages at all since they aren't really important search engine-wise. But if this is the best course of action, how can I just provide a link to the landing page from within the sitemaps framework?
Any suggestions are welcome.
I've included urls for my paginated list views in the XML sitemap using the following code:
from django.conf import settings
from django.contrib.sitemaps import Sitemap
from django.core.paginator import Paginator
from django.core.urlresolvers import reverse
class ArticleListSitemap(Sitemap):
def items(self):
objects = Article.objects.all()
paginator = Paginator(objects, settings.ARTICLE_PAGINATE_BY)
return paginator.page_range
def location(self, page):
return reverse('article_list', kwargs={'page': page})
精彩评论