Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f968d1d

Browse files
authored
Added metadata info when blog post (alshedivat#1573)
Changed metadata info for when page is a blog post. Signed-off-by: George Araujo <[email protected]>
1 parent bdf7bbc commit f968d1d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

_includes/metadata.html

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,17 @@
4141
<meta name="keywords" content="{%- if page.keywords -%}{{ page.keywords }}{%- else -%}{{ site.keywords }}{%- endif -%}" />
4242
{%- endif %}
4343

44-
{%- if site.serve_og_meta %}
44+
{%- assign is_blog_post = false -%}
45+
{%- if page.url != '/blog/index.html' and page.url contains '/blog/' -%}
46+
{%- unless page.url contains '/tag/' or page.url contains '/category/' -%}
47+
{%- assign is_blog_post = true -%}
48+
{%- endunless -%}
49+
{%- endif -%}
4550

51+
{%- if site.serve_og_meta %}
4652
<!-- OpenGraph -->
4753
<meta property="og:site_name" content="{{ title }}" />
48-
<meta property="og:type" content="website" />
54+
<meta property="og:type" content="{%- if is_blog_post -%}article{%- else -%}website{%- endif -%}" />
4955
<meta property="og:title" content="{%- if page.title -%}{{ title }} | {{ page.title }}{%- else -%}{{ title }}{%- endif -%}" />
5056
<meta property="og:url" content="{{ page.url | prepend: site.baseurl | prepend: site.url | remove_first: 'index.html' }}" />
5157
<meta property="og:description" content="{%- if page.description -%}{{ page.description }}{%- else -%}{{ site.description }}{%- endif -%}" />
@@ -193,21 +199,21 @@
193199
{%- endif -%}
194200

195201
<script type="application/ld+json">
196-
{
202+
{
197203
"author":
198204
{
199-
"@type": "Person",
200-
"name": "{{ site.first_name }} {{ site.middle_name }} {{ site.last_name }}"
205+
"@type": "Person",
206+
"name": "{{ site.first_name }} {{ site.middle_name }} {{ site.last_name }}"
201207
},
202208
"url": "{{ page.url | prepend: site.baseurl | prepend: site.url }}",
203-
"@type": "WebSite",
209+
"@type": "{%- if is_blog_post -%}BlogPosting{%- else -%}WebSite{%- endif -%}",
204210
"description": "{%- if page.description -%}{{ page.description }}{%- else if site.description -%}{{ site.description }}{%- endif -%}",
205211
"headline": "{%- if page.title -%}{{ page.title }}{%- else -%}{{ site.title }}{%- endif -%}",
206212
{% if sameaslinks != blank -%}
207213
"sameAs": {{ sameaslinks }},
208214
{%- endif %}
209215
"name": "{{ site.first_name }} {{ site.middle_name }} {{ site.last_name }}",
210216
"@context": "https://schema.org"
211-
}
217+
}
212218
</script>
213219
{%- endif %}

0 commit comments

Comments
 (0)