Opened 3 years ago

Closed 3 years ago

#22231 closed New feature (wontfix)

Subdomain support in Sitemaps

Reported by: anilashanbhag@… Owned by: nobody
Component: contrib.sitemaps Version: master
Severity: Normal Keywords:
Cc: pirosb3 Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


Google currently supports adding subdomain urls to sitemaps.
For example can contains links to and


The current django sitemaps framework cannot handle without having to override the get_urls function. One possible easy fix which I am using currently is:

for item in
    loc = self.__get('location', item)
    if not '://' in loc:
        loc = "%s://%s%s" % (protocol, domain, loc)

instead of

for item in
    loc = "%s://%s%s" % (protocol, domain, self.__get('location', item))

This basically checks if the past returned by location is an absolute path. If yes, it does not append the root domain to it.

Change History (3)

comment:1 Changed 3 years ago by anonymous

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

If this fix sounds good, I can probably submit a pull request for the same.

comment:2 Changed 3 years ago by pirosb3

Cc: pirosb3 added

Is anyone doing this? if not I will prepare a patch.

comment:3 Changed 3 years ago by Aymeric Augustin

Resolution: wontfix
Status: newclosed

This isn't an API, it's a hack.

Generally speaking, I'm not convinced that django.contrib.sitemaps should attempt to do this. Django has a fairly strong assumption that a single instance serves a single domain. The current excepted way to serve multiple domains is with multiple instances and django.contrib.sites.

Note: See TracTickets for help on using tickets.
Back to Top