Opened 12 years ago
Closed 12 years ago
#22231 closed New feature (wontfix)
Subdomain support in Sitemaps
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | contrib.sitemaps | Version: | dev |
| 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 |
Description
Google currently supports adding subdomain urls to sitemaps.
For example example.com/sitemap.xml can contains links to sub1.example.com and sub2.example.com.
Reference: https://productforums.google.com/forum/?hl=en#!msg/webmasters/w4gMRNFHMlA/24pUYqi69mkJ
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 self.paginator.page(page).object_list:
loc = self.__get('location', item)
if not '://' in loc:
loc = "%s://%s%s" % (protocol, domain, loc)
instead of
for item in self.paginator.page(page).object_list:
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 by , 12 years ago
comment:3 by , 12 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
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.
If this fix sounds good, I can probably submit a pull request for the same.