diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 0a5ad703..f6991bcf 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -82,14 +82,25 @@ You can set it the same way as the other author properties. For example, you can ### Customizing description length -By default the description is limited to the first 50 words of the full content. +By default, the description is limited to the first 100 words of the full content. -You can adjust this limit either at the page level or at the site level, by using the `seo_description_max_words` page property: +You can adjust this limit at the page level, by using the `seo_description_max_words` page property: ```yml - seo_description_max_words: 100 + seo_description_max_words: 200 ``` +You can also set a default site-wide value for all pages using [Front Matter defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/) in your `_config.yml` file: + +```yml +defaults: + - scope: + path: "" + values: + seo_description_max_words: 200 +``` + + ### Customizing JSON-LD output The following options can be set for any particular page. While the default options are meant to serve most users in the most common circumstances, there may be situations where more precise control is necessary. diff --git a/lib/jekyll-seo-tag/drop.rb b/lib/jekyll-seo-tag/drop.rb index 525e946f..9d4a9f6a 100644 --- a/lib/jekyll-seo-tag/drop.rb +++ b/lib/jekyll-seo-tag/drop.rb @@ -177,7 +177,7 @@ def canonical_url end def description_max_words - @description_max_words ||= page["seo_description_max_words"] || site["seo_description_max_words"] || 50 + @description_max_words ||= page["seo_description_max_words"] || 100 end private diff --git a/spec/jekyll_seo_tag_integration_spec.rb b/spec/jekyll_seo_tag_integration_spec.rb index 2117c51b..58a9af19 100755 --- a/spec/jekyll_seo_tag_integration_spec.rb +++ b/spec/jekyll_seo_tag_integration_spec.rb @@ -352,23 +352,7 @@ end context "description" do - context "with site.seo_description_max_words" do - let(:site) { make_site("url" => "http://example.invalid", "seo_description_max_words" => 6) } - let(:meta) do - { - "title" => "post", - "description" => "For a long time, I went to bed early", - "image" => "/img.png" - } - end - - it "truncates the description" do - expect(json_data["description"]).to eql("For a long time, I went…") - end - end - context "with page.seo_description_max_words" do - let(:site) { make_site("url" => "http://example.invalid", "seo_description_max_words" => 10) } let(:meta) do { "title" => "post",