-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tags to JSON metadata #151
Changes from 4 commits
f82ea47
8d2febf
2ddab03
4868d22
30d4ffc
a2a2c56
8cc9b2d
9aa2cbf
10d5f82
b04f739
fd5246a
5437934
644e976
a0f6588
da498c7
987e1ea
6ebc866
cc02710
8e36fe4
ba16b95
a847a69
318de34
4c577ff
02eb926
3410fee
c31f4c6
89aad3b
74c2d3d
0b289b8
e8e54a9
48ba285
ac0886d
bc32658
6009b49
9ec685a
61d4c91
5b2e8f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,9 @@ | |
{% endif %} | ||
{% endif %} | ||
{% assign seo_author_twitter = seo_author_twitter | replace:"@","" %} | ||
{% if seo_author.name %} | ||
{% assign seo_author_name = seo_author.name %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
{% if page.seo and page.seo.type %} | ||
|
@@ -89,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 %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allow for page.image.url here, else there will be a mess of if interpreting the yaml object when it encounters this unknown yaml field. |
||
{% unless seo_page_image contains "://" %} | ||
{% assign seo_page_image = seo_page_image | absolute_url %} | ||
{% endunless %} | ||
|
@@ -206,28 +209,57 @@ | |
"headline": {{ seo_page_title | jsonify }}, | ||
{% endif %} | ||
|
||
{% if seo_author_name %} | ||
"author": {{ seo_author_name | jsonify }}, | ||
{% endif %} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Author Name |
||
{% 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 %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create image object (as it needs). Height and width are probably required now for some future thinking. Think AMP where they require this information in the markup. Will default back if either no width/height are present, or if no image url is present. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a future iteration, it'd be great if we could calculate the height and width for local images (assuming we can do so safely without adding something like imagemagic). |
||
{% 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 }}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why include the date modified if it's really the publish date? Is there value in doing this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I'd suggest checking what field jekyll-last-modified-at uses, and supporting that, if installed and working. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't know about that plugin, I'll add that in. |
||
{% endif %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you link to some documentation explaining how this information is used? Is there value in providing the modified date when it doesn't differ from the publishing date? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. Google's Docs mention that the Under this documentation, is listed as recommended for AMP pages, and ignored on non-AMP. But then again, it also says that |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a date modified field. Useful when wanting to control this manually. Like when I make a change to the markup file, but I want to override the timestamp given. Will default to page.date if never "modified". Will not exist if neither field present. |
||
{% if seo_description %} | ||
"description": {{ seo_description | jsonify }}, | ||
{% endif %} | ||
|
||
{% if seo_site_logo %} | ||
"publisher": { | ||
"@type": "Organization", | ||
{% if seo_author_name %} | ||
"name": {{ seo_author_name | jsonify }}, | ||
{% endif %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Author Name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand Google's Structured Data Testing Tool requires publisher to be an Organization while Schema.org spec allows Person. So I have to ask, should publisher as an Organization be a person's name, or the site name? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose it depends how your website is created. A valid point. |
||
"logo": { | ||
"@type": "ImageObject", | ||
"url": {{ seo_site_logo | jsonify }} | ||
} | ||
}, | ||
{% endif %} | ||
|
||
{% if seo_type == "BlogPosting" %} | ||
"mainEntityOfPage": { | ||
"@type": "WebPage", | ||
"@id": {{ page.url | replace:'/index.html','/' | absolute_url | jsonify }} | ||
}, | ||
{% endif %} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add mainEntityOfPage when BlogPosting type is chosen. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried read that post 6 six times, studied Schema.org and still couldn't understand this until I saw your example. 😂 Given Schema.org says all webpages are implicitly of Type WebPage (if not defined) this makes sense. Given this tag also applies to "CreativeWork", it would be useful to add that here while we're making this change as it will help with Structured Data validation for that common type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I've added this to my local branch, along with a test. |
||
{% if seo_links %} | ||
"sameAs": {{ seo_links | jsonify }}, | ||
{% endif %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Author Name