Simple static site generator using Django templates.
Pull request Compare This branch is 588 commits behind eudicots:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


What is Cactus

Cactus is a simple but powerful static website generator using the Django template system. Cactus also makes it easy to develop and deploy your site to S3 directly.

Cactus is based on the idea that most dynamicity on websites these days can be done using Javascript and external services while the actual site can stay static. Still, it's nice to use a well known system like Django to generate your site so you can use the template system and other goodies. The static output allows for very fast and easy hosting, especially combined with a cdn like Amazon Cloudfront. More discussion about this at hacker news

Alternatives to Cactus are Hyde and Jekyll but I wanted to build something simpler our in-house designers at Sofa could use more easily.

Examples - Enstore documentation website

Super quick tutorial for the impatient

First install Cactus with the following one liner

curl -L | sh

If you saw no errors, you can now generate a new project like this ~/ create

The path should now contain a basic project layout that you can start editing. To generate your site from source run: ~/ build

This will render your site to [path]/build. But you can also fire up a small webserver that continuously previews your site while building. This should automatically open your browser and preview the site. You can stop the server with control-c. ~/ serve

Once you are ready to deploy your site to S3 you can run the following. You will need your Amazon access keys. If you don't have one yet read how to get one here and here You will also have to come up with an available bucket name for S3. ~/ deploy

Voila. Your Django generated website hosted on S3 generated by Cactus!

Extended guide


You can install Cactus using this one liner in the terminal. It will download, move it to your /usr/local/bin path, make it executable and install the python dependencies.

curl -L | sh

Creating a new project

You can create a new project by generating a new project stucture like this. Make sure the destination folder does not exist yet.

cactus [path] create

If you did not see any errors, the path you pointed to should now look like this.

- build                 Generated site (upload this to your host)
- pages                 Your actual site pages
    - index.html
    - sitemap.xml
    - robots.txt
    - error.html        A default 404 page
- templates             Holds your django templates
    - base.html
- static                Directory with static assets
    - images
    - css
    - js
- extras
    -          Optional hooks to extend building, deploying
    -         Allows for custom page contexts and modification at render time
    -   Holds custom django template tags

Making your site

After generating your site you can start building by adding pages to contents, which can rely on templates. So for example if you want a page /articles/2010/my-article.html you would create the file with directories in your pages folder. Then you can edit the file and use django's template features.

Building your site

When you build your site it will generate a static version in the build folder that you can upload to any host. Basically it will render each page from your pages folder, copy it over to the build folder and add all the static assets to it so it becomes a self contained website. You can build your site like this:

cactus [path] build

Your rendered website can now be found in the [path]/build folder. Cactus can also run a small webserver to preview your site and update it when you make any changes. This is really handy when developing. You can run it like this:

cactus [path] serve

Linking and contexts

Cactus makes it easy to relatively link to pages and static assets inside your project by using the standard context variables STATIC_URL and ROOT_URL. For example if you are at page /blog/2011/Jan/my-article.html and would like to link to /contact.html you would write the following:

<a href={{ ROOT_URL }}/contact.html>Contact</a>

Optionally you can add variables to the context per page, by modifying the context function in

Custom Django template tags



Cactus can deploy your website directly to S3, all you need are your Amazon credentials and a bucket name. Cactus remembers these in a configuration file name config.json to make future deploys painless. The secret key is stored securely in the Keychain or similar services on other OSs.

cactus [path] deploy

After deploying you can visit the website directly. You can find a deploy log at [site url]/versions.txt. When you add a CloudFront CDN, Cactus also will automatically expire all changed files at the edge locations. This may take up to 15 minutes.


Cactus will auto generate a robots.txt and sitemap.xml file for you based on your pages. This will help bots to index your pages for Google and Bing for example.

Advanced usage

Before deploying you could compress your Javascript and CSS using for example Google Closure and CSSMin for even more performant sites.