Set number of paragraphs of excerpts globally

Hello guys,

first of all, thanks for developing Jekyll!
I wonder whether it is possible to globally set the number of paragraphs ,an excerpt should contain, in the config.yml. (I don’t want to add an excerpt_separator or excerpt to every single post.)

Is there any way I can do this? In my config.yml i tried this
excerpt: 2
to set increase the number of paragraphs to 2 but it did not have an effect to my site. (Yes, I restarted the site generator).

Regards Tobias

Hello @TobiGr,
As currently implemented, you can’t change the no’of paragraphs to include in your excerpts (mainly because by default, Jekyll splits the content along the first set of \n\n, i.e. two consecutive newline characters, it encounters…

One workaround is to (for example) define excerpt_separator: "Read More.." in your _config.yml and then insert that string after two paragraphs in each of your documents.
(Which I’m afraid is probably the same amount of work as manually defining an excerpt: [..enter-your-text..] for each document.)

Thanks for that quick reply @ashmaroli!

Are there any plans for adding an excerpt option to the global config? If yes, can I help to get it done?

For now, I use following work around: Get the post content except of the excerpt. Then I split the content after every </p> tag, and only print the first two elements of the array. It isn’t good coding, but at least, I save time :sweat_smile:

1 Like