Skip to content

Commit 4efbca3

Browse files
committed
Use Front Matter defaults for seo_description_max_words
1 parent 1192047 commit 4efbca3

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

docs/advanced-usage.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,25 @@ You can set it the same way as the other author properties. For example, you can
8282

8383
### Customizing description length
8484

85-
By default the description is limited to the first 50 words of the full content.
85+
By default, the description is limited to the first 100 words of the full content.
8686

87-
You can adjust this limit either at the page level or at the site level, by using the `seo_description_max_words` page property:
87+
You can adjust this limit at the page level, by using the `seo_description_max_words` page property:
8888

8989
```yml
90-
seo_description_max_words: 100
90+
seo_description_max_words: 200
9191
```
9292

93+
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:
94+
95+
```yml
96+
defaults:
97+
- scope:
98+
path: ""
99+
values:
100+
seo_description_max_words: 200
101+
```
102+
103+
93104
### Customizing JSON-LD output
94105

95106
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.

lib/jekyll-seo-tag/drop.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def canonical_url
177177
end
178178

179179
def description_max_words
180-
@description_max_words ||= page["seo_description_max_words"] || site["seo_description_max_words"] || 50
180+
@description_max_words ||= page["seo_description_max_words"] || 100
181181
end
182182

183183
private

spec/jekyll_seo_tag_integration_spec.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -352,23 +352,7 @@
352352
end
353353

354354
context "description" do
355-
context "with site.seo_description_max_words" do
356-
let(:site) { make_site("url" => "http://example.invalid", "seo_description_max_words" => 6) }
357-
let(:meta) do
358-
{
359-
"title" => "post",
360-
"description" => "For a long time, I went to bed early",
361-
"image" => "/img.png"
362-
}
363-
end
364-
365-
it "truncates the description" do
366-
expect(json_data["description"]).to eql("For a long time, I went…")
367-
end
368-
end
369-
370355
context "with page.seo_description_max_words" do
371-
let(:site) { make_site("url" => "http://example.invalid", "seo_description_max_words" => 10) }
372356
let(:meta) do
373357
{
374358
"title" => "post",

0 commit comments

Comments
 (0)