Enable the blog plugin by renaming blog.disabled.py
to blog.py
in your site's plugins directory.
Create a directory called posts
in your site's pages
directory.
Write posts by creating Markdown files (with the extension .md
) in your posts
directory.
Here's an example post:
title: Moving my Blog to Cactus
author: Johnny Dangerously
date: 2014-05-01
template: post.html
# Why I Decided to Switch
I think Cactus is a _really_ great tool and also cacti are prickly.
Dates can be either YYYY-MM-DD
or DD-MM-YYYY
.
To keep an in-progress post from being published, simply add the following line to the post's header:
status: draft
Every page will have access to a master posts
list, so you can loop over your posts anywhere:
{% for post in posts %}
Your post's template can access all of its metadata as variables:
<h1>{{ title }}</h1>
<p>by {{ author }}</p>
{{ body }}
You can add any metadata you want. So, for example, you could create a template that relies on cover images, and at the top of your posts just include:
cover-image: http://mycactusblog.s3.amazonaws.com/whatever.jpg
Then in your template you can just do:
<img src="{{ cover-image }}" alt="Whatever"/>
You can customize your blog's path and set some default metadata for posts by adding a "blog"
entry to your site's config.json
:
"blog": {
"path": "articles",
"defaults": {
"author": "Johnny Dangerously",
"template": "post.html"
}
}
The defaults
will serve as fallbacks for missing values and can be overridden on a per-file basis.
Organize your markdown files however you'd like your posts to be accessed. If you want your posts to live at http://example.com/posts/2014/05/post-title.html
, just use the following directory structure:
pages/
posts/
2014/
05/
post-title.md