The art of not writing a lead

19 February 2020

When I started building the main page of this journal, which displays a list of the latest notes, titles were initially followed by a short excerpt. Why? Out of habit, because I have often worked for the press or for sites with a “News” section, a majority of which use the traditional “title, lead, photo” model.

How to generate this extract? Easy with Kirby, the excerpt field method seems appropriate. I decide to cut at 150 characters.

<?= $article->text()->excerpt(150) ?>

It works but cutting in the middle of words bothers me.

I then decide to cut at 30 words. But where is this option in Kirby 3? The Kirby community tells me it doesn’t exist anymore. With Kirby 2 it had some issues: not always precise depending on character encoding, didn’t work with some non-latin languages… It was not replaced.

I roll up my sleeves. Ceating a custom field method shouldn’t take long, as members of the community provided me some links on this topic.
Soon my excerpt is a bit smarter than planned, it avoids cutting before the end of a sentence.

“How do you detect the end of a sentence?” I’m asked in the community. Easy, it’s where the dot is. Even if it fits my immediate need, I quickly understand this approach is fragile:

A real can of worms! Building a robust solution would actually be very complex.

I move on to other things for a while before I ask myself the right question: do I really need this excerpt? What are the benefits?
Not many if I don’t write it specifically to be displayed on the note’s list, under the title. Yet writing these notes in two languages is already time-consuming enough, I’m reluctant to add new constraints.
I see two solutions:

The title + lead couple is interesting for search engines as the lead is typically displayed under the title, and it can then be finely controlled.
But I’d rather go with the simplicity of a title alone, which seems to be the most important element. I also will never be certain that the lead is always shown to the reader in search engines or RSS feeds (are there still people using RSS these days?)

It is easy to lose sight of our goals –especially when we are our own client– and we sometimes need to step back a bit. A technical difficulty and its associated work hours can often be avoided by reframing the problem.
This time the answer to the question “how to generate a good text excerpt” ultimately was “by writing better titles.”

(Mis)quoted: Picasso and great artists Going at it again