Skip to content

Instantly share code, notes, and snippets.

@jessewaites
Created January 18, 2016 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessewaites/425724b1b5b75ae6c037 to your computer and use it in GitHub Desktop.
Save jessewaites/425724b1b5b75ae6c037 to your computer and use it in GitHub Desktop.
<head>
<!-- other stuff in your site header like javascript or whatever above here -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@your_twitter_handle">
<meta name="twitter:creator" content="@your_twitter_handle">
<!-- hardcoding an image here so I don't have to worry about attaching an image to each blog post in the future -->
<meta property="og:image" content="{{ site.url }}/img/twitter_card2.png" />
<meta name="twitter:image:src" content="{{ site.url }}/img/twitter_card2.png">
<meta content="{{ site.title }}" property="og:site_name">
<!-- Set a page title, or default to site title if missing for some reason -->
{% if page.title %}
<meta name="twitter:title" content="{{ page.title }}">
<meta content="{{ page.title }}" property="og:title">
<meta content="article" property="og:type">
{% else %}
<meta name="twitter:title" content="{{ site.title }}">
<meta content="{{ site.title }}" property="og:title">
<meta content="website" property="og:type">
{% endif %}
<!-- set page description or default to site description -->
{% if page.description %}
<meta name="twitter:description" content="{{ page.description }}">
<meta content="{{ page.description }}" property="og:description">
{% else %}
<meta name="twitter:description" content="{{ site.description }}">
<meta content="{{ site.description }}" property="og:description">
{% endif %}
{% if page.url %}
<meta name="twitter:url" content="{{ site.url }}{{ page.url }}">
<meta content="{{ site.url }}{{ page.url }}" property="og:url">
{% endif %}
{% if page.date %}
<meta content="{{ page.date | date_to_xmlschema }}" property="article:published_time">
{% endif %}
{% if page.image %}
<meta content="{{ site.url }}/img/twitter_card2.png" property="og:image">
<meta property="og:image" content="{{ site.url }}/img/twitter_card2.png" />
{% else %}
<meta content="{{ site.url }}/img/twitter_card2.png" property="og:image">
{% endif %}
{% if page.categories %}
{% for category in page.categories limit:1 %}
<meta content="{{ category }}" property="article:section">
{% endfor %}
{% endif %}
{% if page.tags %}
{% for tag in page.tags %}
<meta content="{{ tag }}" property="article:tag">
{% endfor %}
{% endif %}
</head>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment