Skip to content
cloudhead edited this page Sep 13, 2010 · 3 revisions

A collection of things that are short enough that don’t need their own page. (if you want to expand on them in separate page, go ahead!)

Using markdown in your templates

In your templates, Toto exposes the markdown method, so you can parse markdown in any text or metadata. A common use case is parsing markdown in the title of your post, which Toto doesn’t do by default. To do so, add <%= markdown article.title %> to your template.

Adding extra metadata (such as tags or categories) to your post

Metadata is no different than the other attributes of your articles, such as the date, title, or author. So adding your own metadata is simply a matter of adding some extra attributes to the article YAML headers.
In the article templates, you can usually access the extra YAML information just like any other property of your article. For instance, to list all the tags a post may have (presuming they are space seperated) you can use:

<% article[:tags].split.each do |tag| %>
  <a href="/tags/<%= tag %>"><%= tag %></a>
<% end %>

This presumes you added something like

tags: foo bar baz

to your article.

Accessing article data from the layout

Article metadata is available via the @context variable, when not in the article templates. This is useful for adding <meta> tags in your <head>, with article information.