Using Custom Post Excerpt in Ghost Themes
Ghost Blogging Platform is available publicly now. Designers & developers have started creating stuff around it, most popularly the Ghost themes.
You don’t need advance programming knowledge to develop Ghost themes, its as easy as your write HTML pages! I’ll recommend you to read the theme docs to start developing with Ghost.
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 or summary in Ghost themes.
Custom excerpts in Ghost: Way easier than WordPress
What’s an excerpt? Basically its a synonym of the word summary. In the context of web publishing, you generally see post excerpts on blogs and websites, that are short content summaries extracted from the full post.
Its not a comparison of Ghost and WordPress, but the excerpt word always reminds you & me of WordPress excerpts. Customizing Ghost excerpts is way easier than that of WordPress, but as of now, you can customize their length only.
Note that the handlebars with excerpt-like functionality are used in the index.hbs
file of Ghost themes in general. Look at the theme file structure for a better overview.
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"}}
You may experiment further with the word count, their appearance, wrapping excepts besides post thumbnails or stuff like that.
That’s it. Hope it helps, let me know your thoughts on this.
Load Comments...