Skip to content

Commit

Permalink
Improve meta tags
Browse files Browse the repository at this point in the history
  • Loading branch information
PeeterPaal committed Mar 9, 2022
1 parent ad5c976 commit 4b302a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
39 changes: 17 additions & 22 deletions components/template-meta.tpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
{% comment %}TEMPLATE META DATA{% endcomment %}
{% comment %}https://developers.facebook.com/tools/debug - Debug after each modification{% endcomment %}
{% if site.data.fb_admin %}<meta property="fb:admins" content="{{ site.data.fb_admin }}">{% endif %}

{%- if article -%}
{%- assign og_obj = article -%}
{%- elsif product -%}
{%- assign og_obj = product -%}
{%- else -%}
{%- assign og_obj = page -%}
{%- endif -%}

<meta property="og:type" content="{% if article %}article{% else %}website{% endif %}">
<meta property="og:url" content="{{ site.url }}{% if article %}{{ article.url | remove_first:'/' }}{% elsif product %}{{ product.url | remove_first:'/' }}{% else %}{{ page.url | remove_first:'/' }}{% endif %}">
<meta property="og:url" content="{{ site.url }}{{ og_obj.url | remove_first:'/' }}">
<meta property="og:title" content="{% title %}">
<meta property="og:site_name" content="{{ page.site_title | escape }}">

{% comment %}Open Graph image{% endcomment %}
{% if page.image == nil and front_page %}
{% if main_bg_image_sizes != nil and main_bg_image_sizes != '' %}
{% if main_bg_image_sizes != blank %}
{% for size in main_bg_image_sizes reversed %}
{% if size.width <= 1280 %}
{% assign og_image = size %}
Expand All @@ -18,16 +27,8 @@
{% endfor %}
{% endif %}
{% else %}
{% if article %}
{% if article.image? %}
{% assign og_image = article.image.for-width-1200 %}
{% endif %}
{% elsif product %}
{% if product.image? %}
{% assign og_image = product.image.for-width-1200 %}
{% endif %}
{% elsif page.image? %}
{% assign og_image = page.image.for-width-1200 %}
{% if og_obj.image? %}
{% assign og_image = og_obj.image.for-width-1200 %}
{% endif %}
{% endif %}

Expand All @@ -40,16 +41,10 @@
{% endif %}

{% comment %}Open Graph description{% endcomment %}
{% if article %}
{% assign description = article.description %}
{% else %}
{% assign description = page.description %}
{% endif %}

{% if description != nil and description != '' %}
<meta property="og:description" content="{{ description | escape }}">
<meta name="description" content="{{ description | escape }}">
{% endif %}
{%- if og_obj.description != blank -%}
<meta property="og:description" content="{{ og_obj.description | strip_html | escape_once }}">
<meta name="description" content="{{ og_obj.description | strip_html | escape_once }}">
{%- endif -%}

{% comment %}SEO pagination for blog articles.{% endcomment %}
{% if article %}
Expand Down
2 changes: 1 addition & 1 deletion components/template-settings.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
{% include 'template-settings-json' %}
{%- endcapture -%}

{%- assign template_settings = template_settings_json | replace: "PREFIX", 'zurich' | json_parse -%}
{%- assign template_settings = template_settings_json | replace: 'PREFIX', 'zurich' | json_parse -%}

0 comments on commit 4b302a1

Please sign in to comment.