Summary/excerpt size

I just realized there seems no way to limit the size of a summary/excerpt to a max. number of words, as the configurable Parameter size in the site.yaml counts characters.
This does not look well when words are truncated, IMHO.
is there anyone else who agrees ?
(I’m thinking about creating an issue in the grav 2.0 roadmap - would be cool to have some supporters then :smiley: )

Grav uses a carefully selected set of top notch libraries. In this case it’s Twig which comes to the rescue, see Grav issue “Word truncated in summary.” #1510.

1 Like

Thanks, Ron,
that was the missing hint :smile: - I had searched for summary, excerpt etc. but not found the link you provided.
the only drawback I can see: the filter obviously ignores the size parameter in site.yaml.
it has to be provided in the twig for the filter.

Can you elaborate on “has to be provided in the twig for the filter”?

sure, I had to use

{{ page.summary|safe_truncate(550)  }}

to get truncate to use the intended no# of characters.
omitting the (550) - which I had used before and hoped my setting in site.yaml would be respected, turned out to be ignored.

You could go with something like that:
{{ page.summary|safe_truncate(site.summarysize) }}

summarysize being defined in site.yaml

tried that, but didn’t work, unfortunately.
but that’s not a real problem - I can live well with the mentioned solution (put #no characters as numeric parameter for save_truncate() ).