Skip to main content

SEO support for angular, backbone, and other js apps via django

Project description


![Build status](

django-seo-js is a drop-in app that provides full SEO support for angular, backbone, ember,, and other SPA apps built with django.

It's simple to set up, configurable to use multiple services, and easy to customize.

- [Installation](
- [Options](
- [General Settings](
- [Backend settings](
- [](
- [Custom-hosted prerender](
- [How it all works](
- [Contributing](
- [Releases](

# Installation

Pip install:

pip install django-seo-js

Add to your ``:

# If in doubt, just include both. Details below.
'django_seo_js.middleware.HashBangMiddleware', # If you're using #!
'django_seo_js.middleware.UserAgentMiddleware', # If you want to detect by user agent

INSTALLED_APPS += ('django_seo_js',)

# If you're using (the default backend):
SEO_JS_PRERENDER_TOKEN = "123456789abcdefghijkl"

Add this to your `base.html`

{% load django_seo_js %}
{% seo_js_head %}

That's it! Your js-heavy pages are now rendered properly to the search engines. Have a lovely day.

# Updating the render cache

If you know a page's contents have changed, some backends allow you to manually update the page cache. `django-seo-js` provides helpers to make that easy.

from django_seo_js.helpers import update_cache_for_url


So, for instance, you might want something like:

def listing_changed(sender, instance, created, **kwargs):
update_cache_for_url("%s%s" % ("", reverse("listing_detail",

post_save.connect(listing_changed, sender=Listing)

# Options

## General settings

For the most part, you shouldn't need to override these - we've aimed for sensible defaults.

# Backend to use
SEO_JS_BACKEND = "django_seo_js.backends.PrerenderIO" # Default

# Whether to run the middlewares and update_cache_for_url. Useful to set False for unit testing.
SEO_JS_ENABLED = True # Defaults to *not* DEBUG.

# User-agents to render for, if you're using the UserAgentMiddleware
# Defaults to the most popular. If you have custom needs, pull from the full list:
"Ask Jeeves",

## Backend settings

django-seo-js defaults to using because it's both [open-source]( if you want to run it yourself, *and* really reasonably priced if you don't.

To use [](,

# token
SEO_JS_PRERENDER_TOKEN = "123456789abcdefghijkl"

You don't need to set `SEO_JS_BACKEND`, since it defaults to `django_seo_js.backends.PrerenderIO`.

### Custom-hosted prerender

If you're hosting your own instance of [prerender](, configuration is similar

SEO_JS_BACKEND = "django_seo_js.backends.PrerenderHosted"

## How it all works

If you're looking for a big-picture explanation of how SEO for JS-heavy apps is handled, the clearest explanation I've seen is [this StackOverflow answer](

If even that's TL;DR for you, here's a bullet-point summary:

- If requests come in with an `_escaped_fragment_` querystring or a particular user agent, a pre-rendered HTML response is served, instead of your app.
- That pre-rendered HTML is generated by a service with a headless browser that runs your js then caches the rendered page.
- Said service is generally a third party (there are many: [](, [Brombone](, [seo.js](, [seo4ajax]( You can also run such a service yourself, using [prerender](, or re-invent your own wheel for fun.

# Contributing

PRs with additional backends, bug-fixes, documentation and more are definitely welcome!

Please add tests to any new functionality - you can run tests with `python test`

# Releases

### 0.1.3 - May 13, 2014

* Adds a `SEO_JS_ENABLED` setting, so you can disable hooks and middlewares during tests.

### 0.1.2 - May 9, 2014

* Handles cases where a request didn't come with a User-agent.

### 0.1.1 - May 9, 2014

* Improvements to unit tests.

### 0.1 - May 8, 2014

* Includes `PrerenderIO` and `PrerenderHosted` backends.
* First release - we're using this in production at [GreenKahuna ScrapBin](

Project details

Release history Release notifications

History Node


History Node


History Node


History Node


History Node


History Node


This version
History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-seo-js-0.1.3.tar.gz (9.2 kB) Copy SHA256 hash SHA256 Source None May 13, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page