Django SEO: Meta Tags, A Quick Overview

by Applied Informatics

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Django’s primary goal is to ease the creation of complex, database-driven websites. Django SEO is a Django Based Frame work, allowing you to manage SEO (Search Engine Optimisation) metadata. It is a library that handles metadata defined by you.

Meta: A meta description tag is a code snippet of HTML in head section that outlines the content that is on the web page. The meta description is usually placed after the title tag and before meta keywords tag. When optimizing a web page for search engines (SEO), it is considered a best practice to use meta description tags. Metadata is “data about data”. Two types of metadata exist: structural metadata and descriptive metadata. Structural metadata is data about the containers of data. Descriptive metadata uses individual instances of application data or data content.Web pages include metadata in the form of meta tags. Description and keywords in meta tags are commonly used to describe the Web page’s content. Most search engines use these data when adding pages to their search index.

In order to add SEO  to your website, you need to add:

  • Metadata fields you need.
  • Output to your template.


pip install Django Seo

Quick SEO Steps

Step One:

  • Put ‘rollyourown.seo’ to your Installed _Apps File..
  • Make sure “django.core.context_processors.request” is listed in TEMPLATE_CONTEXT_PROCESSORS.

Step Two:

  • Create a file in any app, with the following simple definition: 
from rollyourown import seo

class WebMetadata(seo.Metadata):
    title = seo.Tag(head=True, max_length=68)
    description = seo.MetaTag(max_length=155)
    keywords = seo.KeywordTag()
    heading = seo.Tag(name="h1")
  • Running syncdb adds up the new tables for above class created.

Step Three: Admin

To edit the data in the admin, call register_seo_admin with admin site and metadata definition: 

from rollyourown.seo.admin import register_seo_admin
from django.contrib import admin
from myapp.seo import WebMetadata

register_seo_admin(, WebMetadata)

Step Four: Adding to templates

To get the metadata in your templates, use the {% get_metadata %} template tag: 

{% load seo %} {% get_metadata %}

The above renders like this:

Site Title

If you save the metadata object as a variable, you’ll be able to access the fields individually:

{% load seo %}
{% get_metadata as metadata %}

{{ metadata }}

{{ metadata.heading }}

{{ web_meta.heading.value }}
{{ web_meta.description.value }}

The following is rendered:

Site Title

Site Heading

Site Heading

Site Description

Django SEO can be a very handy tool to define metadata for Search Engine Optimization for your website. It is dynamic in handling data and uses its libraries of tools in managing data.

Leave a Reply

Your email address will not be published. Required fields are marked *

Tools & Practices

Tools and Technologies we use at Applied

Contact us now

Popular Posts