Oh and even simpler are first
and last
. Use dot notation and you can access the entire object.
In your case {{ site.posts.first.title }}
and {{ site.posts.last.title }}
will get the title
of the first and last posts. You can replace title
with any variable available in the post’s YAML Front Matter… date
, content
, excerpt
, etc.