Giter Club home page Giter Club logo

cactus's Introduction

What is Cactus

Cactus is a simple but powerful static website generator using Python and the Django template system. Cactus also makes it easy to develop locally and deploy your site to S3 directly. It works great for company, portfolio, personal, support websites and blogs.

To get a quick overview watch this short video tutorial.

Cactus is based on the idea that most dynamicness on websites these days can be done using Javascript while the actual site can stay static. Static websites are easy to host and typically very fast.

I developed Cactus because I wanted a standard, easy system that designers at Sofa could use to build and deploy fast websites. So typical users would be designers that are tech-savvy, want to use templates, but don't like to mess with setting up django or S3.

Since then it has evolved quite a bit with a plugin system that supports blogging, spriting, versioning and is extensible.

You can find more discussion about static site generators in this Hacker News discussion.

Examples

There is also an example blog project included.

Super quick tutorial for the impatient

Install Cactus with the following one liner

sudo easy_install https://github.com/koenbok/Cactus/zipball/master

If you saw no errors, you can now generate a new project

cactus create ~/www.mysite.com

To start editing and previewing your site type the following. Cactus will start a small webserver that rebuilds your site as soon as you edit a file. You can stop the server with control-c.

cd ~/www.mysite.com
cactus 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.

cactus deploy

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

Extended guide

Creating a new project

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

cactus create [path]

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
- plugins				A list of plugins. To enable remove disabled from the name

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:

cd [your-cactus-path]
cactus 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 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>

Deploying

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 deploy

After deploying you can visit the website directly. You can find a deploy log at [site url]/versions.txt.

Cactus also makes sure all your text files are compressed and adds caching headers.

Extras

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.

githalytics.com alpha

cactus's People

Contributors

klaaspieter avatar koenbok avatar ryanbagwell avatar tungd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.