-
-
Notifications
You must be signed in to change notification settings - Fork 557
Description
Is your feature request related to a problem? Please describe.
I'm trying to use excerpts to generate my site's meta description tags, but the current implementation only generates an excerpt when the separator is present in my markdown. It's null/undefined otherwise.
Some of my posts use the <!-- excerpt --> separator, but most do not, and I expect I will forget to add it many times in the future.
Describe the solution you'd like
I'd love for a way to generate excerpts for all pages, even when the separator isn't present. This could be done via character limit, word limit, or paragraph count — any of these would be better than the current behavior, IMO.
I'd like to be able to do something like this to configure it:
eleventyConfig.setFrontMatterParsingOptions({
excerpt: true,
excerpt_alias: '<!-- excerpt -->',
excerpt_char_limit: 180, // specify a truncation option to use if the excert_alias is missing
});
It might make sense to leave the current behavior as is, unless this new option is specified.
Describe alternatives you've considered
There's clearly a need here, as I found several blog posts — however most of these solutions were tailored towards collections, not individual pages, and it's taking some work for me to adapt their approaches:
- https://www.belenalbeza.com/articles/better-excerpts-in-eleventy/
- https://www.jonathanyeong.com/garden/excerpts-with-eleventy/
- https://keepinguptodate.com/pages/2019/06/creating-blog-with-eleventy/#displaying-excerpts-on-the-homepage
I'm currently using {{ content | striptags() | truncate(160) }} in my include'd template partial, but this uses the final rendered HTML, so it has extra content such as the post date and title that I render before the main body of my page. I'd like to keep that stuff out of my summary.
Additional context
No response