diff --git a/README.md b/README.md index 06a5c89..a01ecdc 100644 --- a/README.md +++ b/README.md @@ -215,10 +215,9 @@ Or if you have no site specific images simply: ```yml image: path: /img/banner.png - height: 100 - width: 100 ``` +> Using the image dimensions are optional, but the [Google Structured Data Testing Tool](https://search.google.com/structured-data/testing-tool/u/0/) will consider the JSON-LD to have errors when an image does not have specified dimensions. ### Setting a default image diff --git a/lib/template.html b/lib/template.html index 1438e4b..a872638 100755 --- a/lib/template.html +++ b/lib/template.html @@ -266,7 +266,7 @@ }, {% endif %} -{% if seo_type == "BlogPosting" %} +{% if seo_type == "BlogPosting" or seo_type == "CreativeWork" %} "mainEntityOfPage": { "@type": "WebPage", "@id": {{ page.url | replace:'/index.html','/' | absolute_url | jsonify }} diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index bbae600..0d12b77 100644 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -250,6 +250,16 @@ describe Jekyll::SeoTag do end end + context "with seo type is CreativeWork" do + let(:site) { make_site("url" => "http://example.invalid") } + let(:page) { make_post("seo" => { "type" => "CreativeWork" }, "permalink" => "/foo/") } + + it "outputs the mainEntityOfPage" do + expect(json_data["mainEntityOfPage"]["@type"]).to eql("WebPage") + expect(json_data["mainEntityOfPage"]["@id"]).to eql("http://example.invalid/foo/") + end + end + context "with site.title" do let(:site) { make_site("title" => "Foo", "url" => "http://example.invalid") }