Enable the Posts extension

_ext/pipeline.rb
extension Awestruct::Extensions::Posts.new('/blog')

Create the blog directory

$ mkdir blog

Draft a post in Textile

blog/2012-11-27-welcome-to-rwx-2012.textile
---
layout: post
title: Welcome to RWX 2012
author: Dan
---
Welcome to sunny Ft. Lauderdale for RWX 2012!

Draft another post in Textile

blog/2012-11-28-are-you-awestruct.textile
---
layout: post
title: Are you awestruct?
author: Dan
---
What will it take to impress your hacker instinct?

Draft a post in Markdown

blog/2012-11-30-thats-a-wrap.md
---
layout: post
title: That's a wrap?
author: Dan
---
Go enjoy the beach!

Create the layout for a post

_layouts/post.html.haml
---
layout: base
---
#content
  %article
    %header.page-header
      %h1.title
        %a{:href=>page.qurl}= page.title
      .meta
        %time= page.date.strftime("%B %e, %Y")
    .content
      ~ page.content

Show all posts

index.html.haml
---
layout: base
---
#content
  - for post in site.posts
    %article
      %header.page-header
        %h1.title
          %a{:href=>post.qurl, :title=>'Click to go to post', :rel=>'tooltip'}= post.title
        .meta
          %time= post.date.strftime("%B %e, %Y")
      .content
        ~ post.content

Preview!

awestruct -d

Tidy the URLs

_ext/pipeline.rb
extension Awestruct::Extensions::Indexifier.new

Add the Indexifier extension after the Posts extension.

Enable the Pagination extension

_ext/pipeline.rb
extension Awestruct::Extensions::Paginator.new(:posts, '/index', :per_page => 2)

Add the Paginator extension after the Posts extension.

Show paginated posts

index.html.haml
#content
  - for post in page.posts

After changing site.posts to page.posts, notice one entry is missing.

index.html.haml
.pagination
  %ul
    %li
      - if page.posts.previous_page
        %a{:href=>page.posts.previous_page.url}
          %span.icon-step-backward
    %li
      - if page.posts.next_page
        %a{:href=>page.posts.next_page.url}
          %span.icon-step-forward

Add an Atom feed

_ext/pipeline.rb
extension Awestruct::Extensions::Atomizer.new(:posts, '/feed.atom')

Add the Atomizer extension after the Indexifier extension.

Create an archive page

blog/index.html.haml
---
layout: base
---
.page-header
  %h1 Blog Archive
- for year, posts_by_year in site.posts_archive.posts
  - for month, posts_by_month in posts_by_year
    %h2
      = year
      %small= posts_by_month.first[1].first.date.strftime('%B')
    %ul.unstyled
      - for date, posts_by_date in posts_by_month
        - for post in posts_by_date
          %li
            = post.date.strftime('%b %e')
            %a{:href=>post.url}= post.title
Warning
Currently requires a patch to the Posts extension
_layouts/base.html.haml
%li
  %a{ :href=>"#{site.base_url}/blog" } Archive
%li
  %a{ :href=>"#{site.base_url}/feed.atom" } Feed

Add Google Analytics

_ext/pipeline.rb
helper Awestruct::Extensions::GoogleAnalytics

Add helpers after the extensions.

_layouts/base.html.haml
- if site.google_analytics
  = google_analytics_async

Add analytics key to the configuration:

_config/site.yml
google_analytics: UA-00000000-1