Skip to content

Instantly share code, notes, and snippets.

@Chrisedmo
Created August 21, 2012 11:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chrisedmo/3414606 to your computer and use it in GitHub Desktop.
Save Chrisedmo/3414606 to your computer and use it in GitHub Desktop.
Shopify: Facebook OG Tags
{% comment %}
This is for widgets that share content on Facebook.
See the Facebook Linter: http://developers.facebook.com/tools/debug
{% endcomment %}
{% if template contains 'product' %}
<meta property="og:url" content="{{ shop.url }}{{ product.url }}" />
<meta property="og:title" content="{{ product.title }}" />
<meta property="og:description" content="{{ product.description | strip_html | truncatewords: 100, '' | escape }}" />
<meta property="og:image" content="{{ product.featured_image | product_img_url: 'medium' }}" />
{% elsif template contains 'article' %}
<meta property="og:url" content="{{ shop.url }}{{ article.url }}" />
<meta property="og:title" content="{{ article.title }}" />
<meta property="og:description" content="{{ article.excerpt_or_content | strip_html | truncatewords: 100, '' | escape }}" />
{% if article.content contains "<img" %}
{% assign src = article.content | split: 'src="' %}
{% assign src = src[1] | split: '"' | first | replace: '//cdn', 'http://cdn' | replace: 'http:http://', 'http://' | remove: 'https:' %}
{% if src %}<meta property="og:image" content="{{ src }}" />{% endif %}
{% endif %}
{% else %}
{% if settings.use_logo %}
<meta property="og:image" content="{{ 'logo.png' | asset_url }}" />
{% endif %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment