Jan 24, 2014

Using Custom Post Excerpts in Ghost Themes

Ghost Blogging Platform is available publicly now, and developers have started programming stuff around it, most commonly, Ghost themes.

Ghost has a very simplified set of theme functions, basically it makes use of Handlebars (that’s what they call the functions).

Take post content as an example. You basically use the {{content}} handlebar to show up the post content in the Ghost post loop. Similarly you have the {{excerpt}} to display post summary or excerpt.

In this article, we’ll cover the ways to show the custom post excerpts in Ghost themes.

Custom excerpts in Ghost: Way easier than WordPress

This post is not a comparison of Ghost and WordPress, but the excerpt word always reminds you of WordPress excerpts. Customizing Ghost excerpts is way easier than that of WordPress, but as of now, you can customize their length only.

There are two ways to show post excerpts in a Ghost theme; first: using the {{content words="n"}} handlebar, where n is the number of words you want to show in the summary.

The other, semantically correct way to do that is through {{excerpt}}, that shows a summary of the post without having to add a words attribute. But still you’re allowed to alter the excerpt length by using the same attribute.

So, if you want to display the summary with a length of 20 words, you should write:

{{excerpt words="20"}}

That’s it.

Rahul C.

Rahul C. is a web developer running W3Bits since 2012. He loves making things on the internet and sharing his extensive knowledge about front-end web development.

Want to stay up to date?

Sign up for our email newsletter.

Only the relevant, to-the-point content. Zero spam.