Skip to content

Instantly share code, notes, and snippets.

@codegangsta
Created February 10, 2016 01:16
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 codegangsta/5ee47c75c0a5c4498af3 to your computer and use it in GitHub Desktop.
Save codegangsta/5ee47c75c0a5c4498af3 to your computer and use it in GitHub Desktop.
og_tags.liquid
{% if template contains 'sales_page' %}
<meta property="og:type" content="product">
<meta property="og:title" content="{{ sales_page.title | escape }}">
<meta property="og:description" content="{{ sales_page.body | strip_html | escape | truncate: 300 }}">
{% if sales_page.thumbnail_url %}
<meta property="og:image" content="{{ sales_page.thumbnail_url }}">
{% endif %}
{% elsif template contains 'blog_post' %}
<meta property="og:type" content="article">
<meta property="og:title" content="{{ blog_post.title }}">
<meta property="og:description" content="{{ blog_post.content | strip_html | escape | truncate: 300 }}">
{% if blog_post.image_url %}
<meta property="og:image" content="{{ blog_post.image_url }}">
{% endif %}
{% else %}
<meta property="og:type" content="website">
<meta property="og:title" content="{{ current_site.title }}">
{% assign logo_url = "nav_logo.png" | asset_url %}
{% if logo_url %}
<meta property="og:image" content="https:{{ logo_url }}">
{% endif %}
{% endif %}
<meta property="og:url" content="{{ canonical_url }}">
<meta property="og:site_name" content="{{ current_site.title | escape }}">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment