In the Jekyll theme I’m using, the post.excerpt variable seems to have an issue, it outputs the whole content instead of just first 50 words. Hence, I’m compelled to manually extract the 50 words and generate the excerpt out of the content like this:
Since I have to do it at many places (index page of the blog, tags page, header include for the meta attribute, etc.), is there a shorter way so that I can assign this whole thing at one place and then it works automatically from there? I tried doing this but didn’t work:
The github source for my jekyll blog is here, it is in fact a fork of the widely used Hyde template.
Can you elaborate on that with an example or something? All I want to do is to turn this whole construct into a reusable function or something that I can put in the config.yml or any other place:
I use the title in the front matter for that, then you can use that as the title of the page.
Descriptions I usually do manually the same way - front matter, then you can pull that in as the meta description.
I’ve not used the excerpt other than to play with it. There is also an excerpt separator you can use to specify what exactly the excerpt is.
As for how to use an include for what you want, I am not sure it would work but it might. Includes can have data passed in as a parameter and then in the include file you could so what you are doing with the truncate filter.