Created
October 20, 2011 13:21
-
-
Save resistorsoftware/1301130 to your computer and use it in GitHub Desktop.
Meta-Titler Gist for themes with built in settings for Title and Description
This file contains hidden or 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
| {% assign maxwords = 30 %} | |
| {% if template == 'product' %} | |
| {% if collection %} | |
| <link rel="canonical" href="{{ shop.url }}{{ product.url }}" /> | |
| {% endif %} | |
| {% assign mf = product.metafields.meta_data %} | |
| {% unless mf == empty %} | |
| {% for mf in product.metafields.meta_data' %} | |
| {% capture key %}{{ mf | first }}{% endcapture %} | |
| {% if key == 'title' %} | |
| <title>{{mf | last}}</title> | |
| <meta name="title" content="{{mf | last}}" /> | |
| {% endif %} | |
| {% if key == 'meta_description' %} | |
| <meta name="description" content="{{mf | last}}" /> | |
| {% endif %} | |
| {% if key == 'keywords' %} | |
| <meta name="keywords" content="{{mf | last}}" /> | |
| {% endif %} | |
| {% endfor %} | |
| {% endunless %} | |
| {% elsif template contains 'page' %} | |
| {% assign mf = page.metafields.meta_data %} | |
| {% unless mf == empty %} | |
| {% for mf in page.metafields.meta_data' %} | |
| {% capture key%}{{ mf | first }}{%endcapture%} | |
| {% if key == 'title' %} | |
| <title>{{mf | last}}</title> | |
| <meta name="title" content="{{mf | last}}" /> | |
| {% endif %} | |
| {% if key == 'meta_description' %} | |
| <meta name="description" content="{{mf | last}}" /> | |
| {% endif %} | |
| {% if key == 'keywords' %} | |
| <meta name="keywords" content="{{mf | last}}" /> | |
| {% endif %} | |
| {% endfor %} | |
| {% endunless %} | |
| {% elsif template == 'collection' %} | |
| <title>{{ shop.name }} - {{ page_title | escape }}</title> | |
| <meta name="description" content="{{collection.description | strip_html | strip_newlines | truncatewords: maxwords | escape}}" /> | |
| {% elsif template == 'index' %} | |
| {% if settings.home_title_tag != "" %} | |
| <title>{{ settings.home_title_tag }}</title> | |
| {% else %} | |
| <title>{{ shop.name }} - {{ page_title | escape }}</title> | |
| {% endif %} | |
| {% unless settings.meta_description == "" %} | |
| <meta name="description" content="{{ settings.meta_description }}" > | |
| {% endunless %} | |
| {% else %} | |
| {% unless settings.meta_description == "" %} | |
| <meta name="description" content="{{ settings.meta_description }}" > | |
| {% endunless %} | |
| {% if settings.home_title_tag != "" %} | |
| <title>{{ settings.home_title_tag }}</title> | |
| {% else %} | |
| <title>{{ shop.name }} - {{ page_title | escape }}</title> | |
| {% endif %} | |
| {% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment