Skip to main content

Manage website copy as a directory of markdown-formatted files. Insert files as copy into your Django templates.

Project description

Copyblock came out of a desire of mine to separate the copy for a site I’m working on from the site templates. Things like welcome messages, intro copy for forms, etc. This is copy I’d like to be able to tweak easily over time without having to redeploy the entire site to make it happen. What I wanted was a system kindof like gettext, but without .po files, the weird syntax, and a separete app to generate the right files.

What I wanted was really simple: a directory of text files, optionally in Markdown, that could be inserted into my app templates with a template tag. That’s what Copyblock does.


From Pypi:

% pip install django-copyblock

From Github:

% pip install -e git://


Create a root directory for your copyblock files:

%  mkdir copy/dir

Add this path to your settings file:


In your templates:

{% copyblock filename %}

This will do the following:

  • Look for copy/dir/filename.markdown
  • Run the file filename.markdown through markdown
  • Cache the output for future lookups
  • Insert the output in the rendered template

Right now, copyblock only does markdown. If your copy is not in markdown (plain text), you can pass in the nomarkdown parameter to the template tag:

{% copyblock filename nomarkdown %}

Also, if you don’t want to use the in-memory cache (load copy from file every time, good for copy editing), pass in the nocache parameter:

{% copyblock filename nocache %}

When working on site copy, it can be helpful to turn off the Copyblock cache completely with (in


Serving Copyblock Files

Copyblock provides a simple app that will serve Markdown files in your COPYBLOCK_ROOT on the url endpoint of your choosing:

In, set the template name (in your main application) to render markdown files through:


This template should contain an output template variable, like so:

{{ output|safe }}

In, add:

urlpatterns += patterns('',
    url(r'^site/(?P<path>.+)',   include('copyblock.urls',  namespace="copyblock",  app_name='copyblock')),

The path can be whatever you choose.

Now, accessing in your browser will load the content of the


  • Add support for other text formats, or even HTML (suggestions, request?
  • A view that will render any file in settings.COPYBLOCK_ROOT through the site’s base template (base.html) under a path determined by IE, /path/to/copy/dir/foo.markdown would be viewable at Or, something like that. [DONE]

Project details

Download files

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

Files for django-copyblock, version 0.5.3
Filename, size File type Python version Upload date Hashes
Filename, size django-copyblock-0.5.3.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page