Skip to content

Commit

Permalink
Split schema to a separate include file (mmistakes#3085)
Browse files Browse the repository at this point in the history
* Make changes to schema easier

* Only show on one page not on all pages

* Move schema.html to _includes/ and move the URL guard out

---------

Co-authored-by: iBug <[email protected]>
  • Loading branch information
lsolesen and iBug authored May 5, 2024
1 parent 16103c6 commit 2f5e771
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
16 changes: 16 additions & 0 deletions _includes/schema.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script type="application/ld+json">
{
"@context": "https://schema.org",
{% if site.social.type == "Organization" %}
"@type": "Organization",
"url": {{ '/' | absolute_url | jsonify }}{% if site.og_image %},
"logo": {{ site_og_image | jsonify }}{% endif %}{% if site.social.links %},
"sameAs": {{ site.social.links | jsonify }}{% endif %}
{% else %}
"@type": "Person",
"name": {{ site.social.name | default: site.name | jsonify }},
"url": {{ '/' | absolute_url | jsonify }}{% if site.social.links %},
"sameAs": {{ site.social.links | jsonify }}{% endif %}
{% endif %}
}
</script>
18 changes: 3 additions & 15 deletions _includes/seo.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,9 @@
<link rel="next" href="{{ paginator.next_page_path | absolute_url }}">
{% endif %}

<script type="application/ld+json">
{
"@context": "https://schema.org",
{% if site.social.type == "Organization" %}
"@type": "Organization",
"url": {{ '/' | absolute_url | jsonify }}{% if site.og_image %},
"logo": {{ site_og_image | jsonify }}{% endif %}
{% else %}
"@type": "Person",
"name": {{ site.social.name | default: site.name | jsonify }},
"url": {{ '/' | absolute_url |jsonify }}{% if site.social.links %},
"sameAs": {{ site.social.links | jsonify }}{% endif %}
{% endif %}
}
</script>
{% if page.url == '/' %}
{% include schema.html %}
{% endif %}

{% if site.google_site_verification %}
<meta name="google-site-verification" content="{{ site.google_site_verification }}" />
Expand Down

0 comments on commit 2f5e771

Please sign in to comment.