Skip to content

Commit dee4a81

Browse files
committed
Merge pull request #34 from benbalter/default-to-post-excerpt
use the page.excerpt if the page.description doesn't exist
2 parents 9f0b656 + 6dab826 commit dee4a81

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/template.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
{% if page.description %}
3939
{% assign seo_description = page.description %}
40+
{% elsif page.excerpt %}
41+
{% assign seo_description = page.excerpt %}
4042
{% elsif site.description %}
4143
{% assign seo_description = site.description %}
4244
{% endif %}

spec/jekyll_seo_tag_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@
3939
expect(subject.render(context)).to match(/<meta property='og:description' content="foo" \/>/)
4040
end
4141

42-
it "uses the site description when no page description exists" do
42+
it "uses the page excerpt when no page description exists" do
43+
page = page({"description" => "foobar"})
44+
context = context({ :page => page })
45+
expect(subject.render(context)).to match(/<meta name="description" content="foobar" \/>/)
46+
expect(subject.render(context)).to match(/<meta property='og:description' content="foobar" \/>/)
47+
end
48+
49+
it "uses the site description when no page description nor excerpt exist" do
4350
site = site({"description" => "foo"})
4451
context = context({ :site => site })
4552
expect(subject.render(context)).to match(/<meta name="description" content="foo" \/>/)

0 commit comments

Comments
 (0)