diff --git a/README.md b/README.md index 58b17fa..8f71d58 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A Jekyll plugin to add metadata tags for search engines and social networks to b Jekyll SEO Tag adds the following meta tags to your site: -* Pages title (with site title appended when available) +* Page title, with site title or description appended * Page description * Canonical URL * Next and previous URLs on paginated pages diff --git a/lib/template.html b/lib/template.html index 3885dd9..e320aba 100755 --- a/lib/template.html +++ b/lib/template.html @@ -5,21 +5,13 @@ {% endif %} {% assign seo_site_title = site.title | default: site.name %} +{% assign seo_page_title = page.title | default: seo_site_title %} +{% assign seo_title = page.title | default: seo_site_title %} -{% if page.title %} - {% assign seo_title = page.title %} - {% assign seo_page_title = page.title %} - - {% if seo_site_title %} - {% assign seo_title = seo_title | append:" - " | append: seo_site_title %} - {% endif %} -{% elsif seo_site_title %} - {% assign seo_title = seo_site_title %} - {% assign seo_page_title = seo_site_title %} - - {% if site.description %} - {% assign seo_title = seo_title | append:" - " | append: site.description %} - {% endif %} +{% if page.title and seo_site_title %} + {% assign seo_title = seo_title | append:" | " | append: seo_site_title %} +{% elsif site.description %} + {% assign seo_title = seo_title | append:" | " | append: site.description %} {% endif %} {% if page.seo and page.seo.name %} diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 38c0360..07ee0ea 100755 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -44,13 +44,47 @@ describe Jekyll::SeoTag do expect(output).to match(expected) end + context "with site.name" do + let(:site) { make_site("name" => "Site Name") } + + it "builds the title with a page title and site name" do + expect(output).to match(%r!