Skip to content
Serve up a robots.txt file in Django with the proper mime type and a full URL link to sitemap.xml
Branch: develop
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


Django Robots

View builds on TravisCI.

Installation from Source

$ git clone
$ cd django-robots
$ python install

Installation via PIP Requirements File

Include in the PIP requirements file the following line:

-e git://

And then install as normal (IE:)

$ pip install -r path/to/requirements/file.txt


$ python test

With TOX

First, install Tox, then run the tests. This will test against the Django versions specified in the environments specified in the tox.ini file

$ pip install tox
$ tox

Setup the Project For the Application

Add to the project's file tuple of installed apps:


In the project's file add:

url(r'^robots.txt', include('django_robots.urls')),

Enable the sites framework in the project's file:

  1. Add 'django.contrib.sites' to your INSTALLED_APPS setting.
  2. Define a SITE_ID setting:
  1. Run syncdb.

From the Django Admin, configure the Domain Name and Display Name for the site, the domain name will be used in the robots.txt file to point to the absolute URL of the site's sitemap.xml file.

Configure the robots.txt Template

By default the robots.txt template only includes a directive to point to the sitemap at http://site_url/sitemap.xml. This should be removed if the site doesn't have an XML sitemap for some reason. If you're using virtualenv, to copy the templates from the project in order to make adjustments to them, cd to the root of the django project and execute the following command:

cp -r ../src/django-robots/django_robots/templates/robots templates/robots

Template Tags Installed


Returns a full URL for the current site including custom protocol and port if set (i.e.

Example usage:

{% load current_site_url %}
{% current_site_url %}
You can’t perform that action at this time.