3.2 KiB
layout | title | date | sidebar | comments | footer |
---|---|---|---|---|---|
page | Blogging Basics | July 19 2011 | false | false | false |
Jekyll has some conventions for blog post file names which are a bit of a pain to manage manually, so Octopress ships with a rake task to make that easier.
Syntax
rake new_post["title"]
new_post
expects a naturally written title and strips out undesirable url characters when creating the filename.
The default file extension for new posts is markdown
but you can configure that in the Rakefile
.
Example
rake new_post["Zombie Ninjas Attack: A survivor's retrospective"]
# Creates the file
source/_posts/2011-07-03-zombie-ninjas-attack-a-survivors-retrospective.markdown
The filename will determine your url. With the default permalink settings the url would be something like
http://site.com/blog/20011/07/03/zombie-ninjas-attack-a-survivors-retrospective/index.html
.
Open a post in a text editor and you'll see a block of yaml front matter which tells Jekyll how to processes posts and pages.
---
layout: post
title: "Zombie Ninjas Attack: A survivor's retrospective"
date: 2011-07-03 5:59
comments: true
categories:
---
Here you can turn comments off and or categories to your post. If you are working on a multi-author blog, you can add author: Your Name
to the
metadata for proper attribution on a post.
Generate & Preview
rake generate # Generates posts and pages into the public directory
rake watch # Watches source/ and sass/ for changes and regenerates
rake preview # Watches, and mounts a webserver at http://localhost:4000
Jekyll's built in WEBrick server is handy, but if you're a POW user, you can set it up to work with Octopress like this.
cd ~/.pow
ln -s /path/to/octopress
cd -
Now that you're setup with POW, you'll just run rake watch
and load up http://octopress.dev
instead.
Pages
You can add pages anywhere in your blog source directory and they'll be parsed by Jekyll. The URL will correspond directly to the filepath, so about.markdown
will become site.com/about.html
. If you prefer the URL site.com/about/
you'll want to create the page as about/index.markdown
.
Octopress has a rake task for creating new pages easily.
rake new_page[super-awesome]
# creates
/source/super-awesome/index.markdown
rake new_page[super-awesome/page.html]
# creates
/source/super-awesome/page.html
Like with the new post task, the default file extension is markdown
but you can configure that in the Rakefile
. A freshly generated page might look like this:
---
layout: page
title: "Super Awesome"
date: 2011-07-03 5:59
comments: true
sharing: true
footer: true
---
The title is derived from the filename so you'll likely want to change that. This is very similar to the post yaml except it doesn't include categories, and you can toggle sharing and comments or remove the footer altogehter. If you don't want to show a date on your page, just remove it from the yaml.