Question

I just installed octopress as a blogging system and built my own little theme. Everything works fine but there's one thing which isn't working yet.

Within a single post view, I don't seem to have a 'post' object. Which means that:

<h1>{{post.title}}</h1>

Generates an empty string. The blog index and the single post view are using the same article header. It's only the single post view where it doesn't work. The blog index works fine.

Does anybody of you know, which object is available for me in a single post view, or how I can access just the title of a post in a single post view?

Was it helpful?

Solution

The post object is created by the post loop and only available inside of the loop.

{% for post in paginator.posts %}  
  <h1>{{ post.title }}</h1>
{% endfor %}

When it comes to generating the page itself, you'll access page data with teh page object.

<h1>{{ page.title }}<h1>

That will get the title for the page currently being generated which is probably what you want to be doing.

OTHER TIPS

<h1>{{post.title}}</h1> is part of custom section?
If you want to add a section to your sidebar, create a new file in source/_includes/custom/asides/.
Whenever you add a section to the sidebar, follow this pattern, with a <section> block and an <h1> for a title. To add it to the sidebar, edit the _config.yml and add it to the list of asides.
More info

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top