Skip to content

Commit

Permalink
use the page.excerpt if the page.description doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed Jan 25, 2016
1 parent 9f0b656 commit 6dab826
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

{% if page.description %}
{% assign seo_description = page.description %}
{% elsif page.excerpt %}
{% assign seo_description = page.excerpt %}
{% elsif site.description %}
{% assign seo_description = site.description %}
{% endif %}
Expand Down
9 changes: 8 additions & 1 deletion spec/jekyll_seo_tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@
expect(subject.render(context)).to match(/<meta property='og:description' content="foo" \/>/)
end

it "uses the site description when no page description exists" do
it "uses the page excerpt when no page description exists" do
page = page({"description" => "foobar"})
context = context({ :page => page })
expect(subject.render(context)).to match(/<meta name="description" content="foobar" \/>/)
expect(subject.render(context)).to match(/<meta property='og:description' content="foobar" \/>/)
end

it "uses the site description when no page description nor excerpt exist" do
site = site({"description" => "foo"})
context = context({ :site => site })
expect(subject.render(context)).to match(/<meta name="description" content="foo" \/>/)
Expand Down

0 comments on commit 6dab826

Please sign in to comment.