Had a go at converting a mostly static but dynamically rendered site to use Jekyll yesterday, it was a lot more straight forward than I thought it was going to be.
As part of the conversion I needed to display the first post differently, after consulting the all knowing Google I settled on the following method;
Jekyll Snippets 1/3
{% for post in site.posts offset: 0 limit: 1 %}
<div class="some-style">
<a href="{{post.url}}">
<h3 class='news-title'>{{ post.title }}</h3>
<span class='news-date'>{{ post.date | date_to_string }}</span>
</a>
<p>{{ page.excerpt }} <a href='{{post.url}}'><span class='read-more'> Read more</span></a></p>
</div>
{% endfor %}
Getting the rest of the posts;
Jekyll Snippets 2/3
{% for post in site.posts offset: 1 limit: 4 %}
<div class="some-other-style">
<a href="{{post.url}}">
<h3 class='news-title'>{{ post.title }}</h3>
<span class='news-date'>{{ post.date | date_to_string }}</span>
</a>
<p>{{ page.excerpt }} <a href='{{post.url}}'><span class='read-more'> Read more</span></a></p>
</div>
{% endfor %}
that worked apart from I need more consistancy with the page.excerpt
to keep things a little more uniform, the following code fitted the bill nicely;
Jekyll Snippets 3/3
{{ post.content | strip_html | truncatewords:75 }}
it even added ...
to the end automagically.
Also, if you don’t know what Jekyll is then have a look at the website or dive straight in with the following simple install guide above.
I will keep the Gist updated as I do more stuff.