Add the rest of the JSON tags to pass blogPosting Errors/Warnings
This adds the rest of the JSON fields to pass all errors and blog postings. - Adds page.image.url for the image url. (Will default to image if not present). - Add page.image.height and page.image.width for an image object (Will default back to image url if not present). - Add dateModified (will capture from yaml if present, if not it will use datePublished) - (I feel there should be a manual option for this as I sometimes save parts of my blog that shouldn't update the modified field, but still change the file timestamp). This should create JSON that will pass all warnings/strong recommendations/errors from [Google's Structured Data Testing Tool](https://search.google.com/structured-data/testing-tool).
This commit is contained in:
parent
2ddab030f3
commit
4868d22b1b
|
@ -92,7 +92,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% if page.image %}
|
||||
{% assign seo_page_image = page.image.path | default: page.image.facebook | default: page.image %}
|
||||
{% assign seo_page_image = page.image.path | default: page.image.url | default: page.image.facebook | default: page.image %}
|
||||
{% unless seo_page_image contains "://" %}
|
||||
{% assign seo_page_image = seo_page_image | absolute_url %}
|
||||
{% endunless %}
|
||||
|
@ -214,13 +214,28 @@
|
|||
{% endif %}
|
||||
|
||||
{% if seo_page_image %}
|
||||
"image": {{ seo_page_image | jsonify }},
|
||||
{% if page.image.height && page.image.width %}
|
||||
"image": {
|
||||
"@type": "ImageObject",
|
||||
"url": {{ seo_page_image | jsonify }},
|
||||
"height": {{ page.image.height | jsonify }},
|
||||
"width": {{ page.image.width | jsonify }}
|
||||
},
|
||||
{% else %}
|
||||
"image": {{ seo_page_image | jsonify }},
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if page.date %}
|
||||
"datePublished": {{ page.date | date_to_xmlschema | jsonify }},
|
||||
{% endif %}
|
||||
|
||||
{% if page.dateModified %}
|
||||
"dateModified": {{ page.dateModified | date_to_xmlschema | jsonify }},
|
||||
{% elseif page.date %}
|
||||
"dateModified": {{ page.date | date_to_xmlschema | jsonify }},
|
||||
{% endif %}
|
||||
|
||||
{% if seo_description %}
|
||||
"description": {{ seo_description | jsonify }},
|
||||
{% endif %}
|
||||
|
@ -238,6 +253,13 @@
|
|||
},
|
||||
{% endif %}
|
||||
|
||||
{% if seo_type == "BlogPosting" %}
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": {{ page.url | replace:'/index.html','/' | absolute_url | jsonify }}
|
||||
},
|
||||
{% endif %}
|
||||
|
||||
{% if seo_links %}
|
||||
"sameAs": {{ seo_links | jsonify }},
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in New Issue