Skip to content

Commit 2f5e771

Browse files
lsoleseniBug
andauthored
Split schema to a separate include file (mmistakes#3085)
* 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]>
1 parent 16103c6 commit 2f5e771

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

_includes/schema.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script type="application/ld+json">
2+
{
3+
"@context": "https://schema.org",
4+
{% if site.social.type == "Organization" %}
5+
"@type": "Organization",
6+
"url": {{ '/' | absolute_url | jsonify }}{% if site.og_image %},
7+
"logo": {{ site_og_image | jsonify }}{% endif %}{% if site.social.links %},
8+
"sameAs": {{ site.social.links | jsonify }}{% endif %}
9+
{% else %}
10+
"@type": "Person",
11+
"name": {{ site.social.name | default: site.name | jsonify }},
12+
"url": {{ '/' | absolute_url | jsonify }}{% if site.social.links %},
13+
"sameAs": {{ site.social.links | jsonify }}{% endif %}
14+
{% endif %}
15+
}
16+
</script>

_includes/seo.html

+3-15
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,9 @@
121121
<link rel="next" href="{{ paginator.next_page_path | absolute_url }}">
122122
{% endif %}
123123

124-
<script type="application/ld+json">
125-
{
126-
"@context": "https://schema.org",
127-
{% if site.social.type == "Organization" %}
128-
"@type": "Organization",
129-
"url": {{ '/' | absolute_url | jsonify }}{% if site.og_image %},
130-
"logo": {{ site_og_image | jsonify }}{% endif %}
131-
{% else %}
132-
"@type": "Person",
133-
"name": {{ site.social.name | default: site.name | jsonify }},
134-
"url": {{ '/' | absolute_url |jsonify }}{% if site.social.links %},
135-
"sameAs": {{ site.social.links | jsonify }}{% endif %}
136-
{% endif %}
137-
}
138-
</script>
124+
{% if page.url == '/' %}
125+
{% include schema.html %}
126+
{% endif %}
139127

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

0 commit comments

Comments
 (0)