diff --git a/.gitignore b/.gitignore index b7e7725..3476aa5 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ /pkg/ /spec/reports/ /tmp/ +/bin/ *.gem diff --git a/README.md b/README.md index fdaffb8..ddcd9a0 100644 --- a/README.md +++ b/README.md @@ -102,12 +102,15 @@ webmaster_verifications: yandex: 1234 ``` +* `lang` - The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`. + The SEO tag will respect the following YAML front matter if included in a post, page, or document: * `title` - The title of the post, page, or document * `description` - A short description of the page's content * `image` - URL to an image associated with the post, page, or document (e.g., `/assets/page-pic.jpg`) * `author` - Page-, post-, or document-specific author information (see below) +* `lang` - Page-, post-, or document-specific language information ## Advanced usage diff --git a/lib/template.html b/lib/template.html index 1922381..c06665c 100755 --- a/lib/template.html +++ b/lib/template.html @@ -97,6 +97,8 @@ {% assign seo_page_image = seo_page_image | escape %} {% endif %} +{% assign seo_page_lang = page.lang | default: site.lang | default: "en_US" %} + {% if seo_tag.title and seo_title %} {{ seo_title }} {% endif %} @@ -109,6 +111,8 @@ {% endif %} + + {% if seo_description %} @@ -124,7 +128,6 @@ {% endif %} {% if seo_page_image %} - {% if page.image.height %} diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index d4593f8..e2bcb0b 100755 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -257,6 +257,7 @@ describe Jekyll::SeoTag do Foo + @@ -581,4 +582,38 @@ EOS end end end + + context "with locale" do + it "uses en_US when no locale is specified" do + expected = %r!! + expect(output).to match(expected) + end + + context "with site.lang" do + let(:site) { make_site("lang" => "en_US") } + + it "uses site.lang if page.lang is not present" do + expected = %r!! + expect(output).to match(expected) + end + + context "with page.lang" do + let(:page) { make_page("lang" => "en_UK") } + + it "uses page.lang if both site.lang and page.lang are present" do + expected = %r!! + expect(output).to match(expected) + end + end + end + + context "with site.lang hyphenated" do + let(:site) { make_site("lang" => "en-US") } + + it "coerces hyphen to underscore" do + expected = %r!! + expect(output).to match(expected) + end + end + end end