Skip to content

Instantly share code, notes, and snippets.

@pathawks
Last active May 20, 2020 19:27
Show Gist options
  • Save pathawks/1406355 to your computer and use it in GitHub Desktop.
Save pathawks/1406355 to your computer and use it in GitHub Desktop.
Open Graph for Jekyll
{% if include.content %}
<meta property="{{ include.property }}" content="{{ include.content }}" />
{% endif %}
{% capture header %}
{% if page.title %}
<meta property="og:type" content="article" />
<meta property="og:title" content="{{ page.title }}" />
{% else %}
<meta property="og:type" content="website" />
{% endif %}
{% include meta.html property="og:site_name" content=site.title %}
{% include meta.html property="og:image" content=page.thumbnail %}
{% capture page_url %}{{ page.url | replace:'/index.html','/' | append: site.url | append: site.baseurl }}{% endcapture %}
{% include meta.html property="og:url" content=page_url %}
{% capture page_date %}{{page.date | date_to_xmlschema}}{% endcapture %}
{% include meta.html property="article:published_time" content=page_date %}
{% if page.author.url %}
<meta property="article:author" content="{{ page.author.url }}" />
<link rel="author" href="{{ page.author.url }}" />
{% elsif site.owner_link %}
<meta property="article:author" content="{{ site.owner_link }}" />
<link rel="author" href="{{ site.owner_link }}" />
{% endif %}
{% endcapture %}{{ header | strip_newlines }}
@akmil
Copy link

akmil commented Feb 1, 2017

maybe it would be better to use 'jekyll-seo-tag' plugin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment