diff --git a/lib/template.html b/lib/template.html index 93e3432..d68b1f8 100644 --- a/lib/template.html +++ b/lib/template.html @@ -84,6 +84,14 @@ {% assign seo_links = site.social.links %} {% endif %} +{% if site.logo %} + {% assign seo_site_logo = site.logo | prepend: seo_url | escape %} +{% endif %} + +{% if page.image %} + {% assign seo_page_image = page.image | prepend: seo_url | escape %} +{% endif %} + {% if seo_tag.title and seo_title %} {{ seo_title }} {% endif %} @@ -106,8 +114,8 @@ {% endif %} -{% if page.image %} - +{% if seo_page_image %} + {% endif %} {% if page.date %} @@ -162,8 +170,8 @@ "headline": {{ seo_page_title | jsonify }}, {% endif %} -{% if page.image %} - "image": {{ page.image | jsonify }}, +{% if seo_page_image %} + "image": {{ seo_page_image | jsonify }}, {% endif %} {% if page.date %} @@ -174,8 +182,8 @@ "description": {{ seo_description | jsonify }}, {% endif %} -{% if site.logo %} - "logo": {{ site.logo | prepend: "/" | prepend: seo_url | jsonify }}, +{% if seo_site_logo %} + "logo": {{ seo_site_logo | jsonify }}, {% endif %} {% if seo_links %} diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 3b9fb2a..0f1bf5f 100644 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -120,7 +120,7 @@ describe Jekyll::SeoTag do end context 'with site.logo' do - let(:site) { make_site('logo' => 'logo.png', 'url' => 'http://example.invalid') } + let(:site) { make_site('logo' => '/logo.png', 'url' => 'http://example.invalid') } it 'outputs the logo' do expect(json_data['logo']).to eql('http://example.invalid/logo.png') @@ -163,6 +163,7 @@ EOS context 'posts' do context 'with post meta' do + let(:site) { make_site('url' => 'http://example.invalid') } let(:meta) do { 'title' => 'post', @@ -178,7 +179,7 @@ EOS expect(json_data['headline']).to eql('post') expect(json_data['description']).to eql('description') - expect(json_data['image']).to eql('/img.png') + expect(json_data['image']).to eql('http://example.invalid/img.png') end it 'minifies JSON-LD' do