annealer annealer

gabriel gironda will have his revenge on seattle

Jekyll tip for rendering individual posts

Written on Sunday, December 28, 2008

When rendering individual posts, your layout may look something like this:

    <div class="post">
      <div class="meta">
        <h3><a href="{ {page.url|xml_escape} }">{ {page.title|xml_escape} }</a></h3>
        <p class="date">Written on { {page.date | date: "%A, %B %d, %Y"} }</p>
      </div>
      <div class="page.content">
        { {page.content} }
      </div>
    </div>

While everything else is done via the page variable (page.title for example), the actual post content should be rendered just by using the content variable, and not page.content as I previously used, making the layout look closer to:

    <div class="post">
      <div class="meta">
        <h3><a href="{ {page.url|xml_escape} }">{ {page.title|xml_escape} }</a></h3>
        <p class="date">Written on { {page.date | date: "%A, %B %d, %Y"} }</p>
      </div>
      <div class="page.content">
        { {content} }
      </div>
    </div>

If you use page.content you’ll be scratching your head at why your posts are rendering as un-marked up and un-syntax-highlighted text. As a side note, if anyone could figure out how to escape Liquid tags so double-curly-braces aren’t interpreted, that’d be swell.

blog comments powered by Disqus

Annealer, a Jekyll powered blog by Gabriel Gironda.