From 160505dcd0432b0788e0f138e80a79ece6034c22 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Fri, 30 Jun 2023 14:32:52 +0200 Subject: [PATCH] Truncate the description value to 280 chars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the value of the `description`, `og: description` and `twitter: description` tags includes the whole text of the post. Which means that, on post pages, the text of the post is included *four* times in the HTML document – adding to the page weight needlessly. This commit ensures the description string is truncated to a sane value. --- lib/jekyll-seo-tag/drop.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/jekyll-seo-tag/drop.rb b/lib/jekyll-seo-tag/drop.rb index 157babd..56a291e 100644 --- a/lib/jekyll-seo-tag/drop.rb +++ b/lib/jekyll-seo-tag/drop.rb @@ -89,7 +89,8 @@ module Jekyll def description @description ||= begin - format_string(page["description"] || page["excerpt"]) || site_description + value = format_string(page["description"] || page["excerpt"]) || site_description + filters.truncate(value, 280) end end