Opened 4 years ago

Closed 2 years ago

#16829 closed New feature (fixed)

sitemap for static views

Reported by: madisv Owned by: zsiciarz
Component: Documentation Version: master
Severity: Normal Keywords: views sitemap
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


People also use static views which are not FlatPages. So it's a problem creating a sitemap for such urls.
This is not hard to do if you know how so should this code maybe also be in django or might we just document this so people would know how to do this.

Problem explained also:

Solution by Matt Austin:
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, 'news_articles': ArticleSitemap}

Change History (9)

comment:1 Changed 4 years ago by carljm

  • Component changed from contrib.sitemaps to Documentation
  • Has patch unset
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

I don't think this code needs to be in Django, but the sitemaps documentation could benefit from an example like this showing how to add static views to a sitemap.

comment:2 Changed 4 years ago by jacob

  • milestone 1.4 deleted

Milestone 1.4 deleted

comment:3 Changed 3 years ago by camilonova

This is a real issue, and i agree with carljm, if you suggest me a place for adding the documentation i can do that.

comment:4 Changed 2 years ago by zsiciarz

  • Owner changed from nobody to zsiciarz
  • Status changed from new to assigned
  • Version changed from 1.3 to master

comment:5 Changed 2 years ago by zsiciarz

comment:6 Changed 2 years ago by zsiciarz

  • Has patch set

comment:7 Changed 2 years ago by pyriku

  • Triage Stage changed from Accepted to Ready for checkin

Looks OK to me

comment:8 Changed 2 years ago by Zbigniew Siciarz <antyqjon@…>

In d77082b43877b4df0f29fa977b73b7b4feab84d4:

Added example of using sitemaps with static views.

References #16829.

comment:9 Changed 2 years ago by timo

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.
Back to Top