-
-
Save rameshanandakrishnan/fc18dd3920151e404f8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Find Current URL for og:url tag | |
https://github.com/joshuacc/Shopify-Snippets/blob/master/find-current-url.liquid --> | |
{% assign current_url = '' %} | |
{% case template %} | |
{% when 'page' %} | |
{% assign current_url = page.url %} | |
{% when 'blog' %} | |
{% assign current_url = blog.url %} | |
{% when 'article' %} | |
{% assign current_url = blog.url %} | |
{% when 'collection' %} | |
{% assign current_url = collection.url %} | |
{% when 'product' %} | |
{% assign current_url = product.url %} | |
{% endcase %} | |
<!-- End Find Current URL --> | |
<!-- Facebook Open Graph --> | |
{% if template contains 'product' %} | |
<meta name="og:image" content="{% for image in product.images %}{{ image.src | product_img_url: 'grande' }}{% endfor %}" /> | |
{% else %} | |
<meta name="og:image" content="{{ 'logo.png' | asset_url }}" /> | |
{% endif %} | |
<meta property="og:url" content="{{ shop.url }}{{ current_url }}" /> | |
<meta property="og:title" content="{{ shop.name }}: {{ page_title }}" /> | |
{% if template contains 'product' %} | |
<meta name="og:description" content="{{ product.description | strip_html | strip_newlines | escape }}" /> | |
{% elsif template contains 'collection' %} | |
<meta name="og:description" content="{{ collection.description | strip_html | strip_newlines | escape }}" /> | |
{% elsif template contains 'page' %} | |
<meta name="og:description" content="{{ page.content | strip_html | strip_newlines | escape }}" /> | |
{% elsif template == 'index' %} | |
<meta name="og:description" content="{{ shop.description | strip_html | strip_newlines | escape}}" /> | |
{% endif %} | |
{% if template contains 'product' %} | |
<meta name="og:type" content="product" /> | |
{% else %} | |
<meta name="og:type" content="website" /> | |
{% endif %} | |
<!-- End Facebook Open Graph --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment