Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

Summary/excerpt size

Solved by Ron Wardenier View solution

Started by Werner Joss 7 years ago · 6 replies · 1265 views
7 years ago

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 😃 )

7 years ago

Thanks, Ron,
that was the missing hint 😄 - 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.

7 years ago

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

7 years ago

sure, I had to use

TWIG
{{ 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.

7 years ago

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

summarysize being defined in site.yaml

7 years ago

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() ).

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 96 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 184 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 147 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 61 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 255 1 year ago