
Jekyll Snippets
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;
{% for post in site.posts offset: 0 limit: 1 %}<div class="some-style"><a href="/assets/2014-02-02-jekyll-snippets/{{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>Getting the rest of the posts;
{% for post in site.posts offset: 1 limit: 4 %}<div class="some-other-style"><a href="/assets/2014-02-02-jekyll-snippets/{{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;
{{ 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.
Share
Related Posts

More site updates
Russ Mckendrick improves blog speed, adds Gruntfile features for testing and deployment to Amazon S3 with Cloudflare cache flushing.

Git + Rebase
Streamline your Git workflow with Russ Mckendrick's tips! Learn how to fork, add remotes, and rebase for maximum efficiency.

More Grunt & Jekyll
Streamlined my Grunt configuration by combining tasks, now I can concatenate JS files, compress them with Uglify, and minify CSS files in one go!