Kirby 3 Chopper plugin for truncating text

Installs: 1 282

Dependents: 0

Suggesters: 0

Security: 0

Stars: 27

Watchers: 1

Forks: 3

Open Issues: 0


3.0.0 2022-04-16 10:17 UTC

This package is auto-updated.

Last update: 2022-08-16 11:22:33 UTC


Kirby's built in Excerpt takes an all or nothing approach to stripping html tags, and only works on characters. This plugin creates excerpts from fields via KirbyText but keeps any HTML tags, with the ability to define the tags you wish to keep. Also works on whole words, as well as characters.

Commerical Usage

This plugin is free but if you use it in a commercial project please consider to



To use this plugin, place all the files in site/plugins/chopper/.


composer require hashandsalt/kirby-chopper


Defaults to limiting to 250 charchters, maintaining whole words, so if you just want 20 words and an ellipsis on the end:

<?= $page->yourtextfield()->chopper() ?>

To set number of charachters to trim to

<?= $page->yourtextfield()->chopper(100) ?>

To trim to 50 charachters, maintaining whole words, append an arrow on the on the end:

<?= $page->yourtextfield()->chopper(50, ['ellipsis', '→']) ?>

To change the default list of kept tags, add this line to your config.php and amend accordingly:

'hashandsalt.chopper.keep' => '<p><a><strong><em><sub><sup><blockquote><figure><img><h1><h2><h3><h4><h5><h6>',

To append every time an arrow at the end, add this line to your config.php:

'hashandsalt.chopper.ellipsis' => '→',


Full list of options

'hashandsalt.chopper.ellipsis' => '…',
'hashandsalt.chopper.exact' => true,
'hashandsalt.chopper.html' => true,
'hashandsalt.chopper.trimWidth' => false,
'hashandsalt.chopper.keep' => '<p><a><strong><em><sub><sup><blockquote><figure><img><h1><h2><h3><h4><h5><h6>',


This plugin was built using Kirby 3.6. Will not work on earlier versions. Requires PHP 7.4+


Based on text functions in CakePHP https://cakephp.org/