Re: Problem using nested layouts with a post, nothing is rendered

228 views
Skip to first unread message

Marcelo de Moraes Serpa

unread,
Feb 10, 2011, 3:00:52 PM2/10/11
to jekyll.rb
Hmm, there is a problem though.

page.content doesn't return the body in paragraphs, i.e:

instead of returning

<p>lorem ipsum dollor</p>
<p>loreim ipsum dollor</p>

It returns

lorem ipsum dollorloremipsuldollor

Any hints?

Marcelo.

On Thu, Feb 10, 2011 at 1:58 PM, Marcelo de Moraes Serpa
<celo...@gmail.com> wrote:
> I solved it. In the post.html include file, I added some liquid code in the top:
>
> {% unless post %}
>  {% assign post = page %}
> {% endunless %}
>
> <div class="entry">
>  <div id="post_title">
>    <h1><a href="{{post.url}}">{{ post.title }}</a></h1>
>    <h4>{{ post.date }}</h4>
>  </div>
>
>  <div id="post_body">
>    {{ post.content }}
>  </div>
>
> </div>
>
> So when the post var is not present, it will actually use the page,
> and that is the case for the individual processed post page, jekyll
> can't find the post var.
>
> Thanks,
>
> Marcelo.
>
> On Thu, Feb 10, 2011 at 11:56 AM, Marcelo de Moraes Serpa
> <celo...@gmail.com> wrote:
>> Hi list!
>>
>> I'm having a small issue with the way I'm trying to setup my site. Let
>> me explain it first.
>>
>> I have a markdown post in _posts that has the following YAML front-
>> matter:
>>
>>>---
>>>layout: post
>>>---
>>
>> The post layout looks like this (in _layouts/post.html)
>>
>>>---
>>>layout: blog_layout
>>>---
>>>
>>>{% include post.html %}
>>
>> The post include file looks like this (in _includes/post.html)
>>
>>><div class="entry">
>>>  <div id="post_title">
>>>    <h1><a href="{{post.url}}">{{ post.title }}</a></h1>
>>>    <h4>{{ post.date }}</h4>
>>>  </div>
>>>  <div id="post_body">
>>>    {{ post.content }}
>>>  </div>
>>></div>
>>
>> And the blog_layout:
>>
>>><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1->transitional.dtd">
>>><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
>>>  <head>
>>>    <link rel="stylesheet" href="/css/style.css" type="text/css" media="screen" title="main style" charset="utf-8"/>
>>>    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
>>>    <meta http-equiv="author" content="Marcelo de Moraes Serpa"/>
>>>  </head>
>>>  <body>
>>>    <div id="wrapper">
>>>      <div id="header" style="width:1023px;height:140px;background-image:url(/images/header_blog.jpg)">
>>>        <h1 class="hidden">FullOfCaffeine Blog</h1>
>>>        <h2 class="hidden">Enlightenment through high-doses of caffeinated content!</h2>
>>>      </div>
>>>      <div id="main">
>>>        {{content}}
>>>        <!-- add post footer with social media elements, et al -->
>>>        <div id="clearer" style="clear:both">
>>>        </div>
>>>
>>>      </div>
>>>      <div id="footer">
>>>        <span style="font-size:12px;margin-right:10px;float:right">2010 / Marcelo.</span>
>>>        <!-- todo here: links, blogrolls, etc -->
>>>      </div>
>>>    </body>
>>>  </html>
>>
>> Now, I have a root blog.html page that iterates over the posts and
>> prints the last 10:
>>
>>>---
>>>layout: blog_layout
>>>title: Writtings Full Of Caffeine
>>>---
>>>
>>>{% for post in site.posts limit:10 %}
>>>{% include post.html %}
>>>{% endfor %}
>>
>> If you check the post.html include file, you'll see that the <h1> has
>> a link to the post ( {{ post.url }} ). What I'd like to do is, the
>> blog.html shows the last 10 posts, and if the user clicks on the
>> title, he/she will jump to this post (I plan to truncate the posts in
>> blog.html to a limited char extension).
>>
>> So, the posts do get listed in the blog.html page, but when I access
>> them individually, I get the whole layout structure rendered, but
>> without any content from the post itself. What am I doing wrong?
>>
>> Thanks!
>>
>> Marcelo.
>>
>>
>>
>>
>

Marcelo de Moraes Serpa

unread,
Feb 10, 2011, 12:56:33 PM2/10/11
to jekyll.rb

Marcelo de Moraes Serpa

unread,
Feb 10, 2011, 2:58:24 PM2/10/11
to jekyll.rb
I solved it. In the post.html include file, I added some liquid code in the top:

{% unless post %}
{% assign post = page %}
{% endunless %}

<div class="entry">


<div id="post_title">
<h1><a href="{{post.url}}">{{ post.title }}</a></h1>
<h4>{{ post.date }}</h4>
</div>

<div id="post_body">
{{ post.content }}
</div>

</div>

So when the post var is not present, it will actually use the page,


and that is the case for the individual processed post page, jekyll
can't find the post var.

Thanks,

Marcelo.

On Thu, Feb 10, 2011 at 11:56 AM, Marcelo de Moraes Serpa
<celo...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages