SSHHH
October 16, 2020, 10:28am
1
Hello Dears,
In order to add meta tags to each page separately I am using an If Else statements.
I am confused because of the URLs of the pages.
Could you please advise how should they be added?
All statements are added in the head tag in theme.liquid file
For example:
For the page https://severinassecrets.com/pages/ssecret-agents
Should the statement be without the “pages/”
{% if page.handle == “ssecret-agents” %}
or with “pages/”:
{% if page.handle == “pages/ssecret-agents” %}
And for our product page:
https://severinassecrets.com/produc…/perfectly-pink-privates
Should it be without “products/”:
{% elsif page.handle == “perfectly-pink-privates” %}
or with “products/”
{% elsif page.handle == “products/perfectly-pink-privates” %}
and lastly for page https://severinassecrets.com/account/login
without the “account/”
{% elsif page.handle == “login” %}
or with “account/”
{% elsif page.handle == “account/login” %}
The Idea is to target each page separately is to add meta tags to it
example:
{% if page.handle == “pages/ssecret-agents” %}
{% elsif page.handle == "our-ssecrets" %}
However the meta tags are not applied correctly to the pages possibly due to wrong if else path > {% if page.handle == “pages/ssecret-agents” %}
Thanks in advance!
Hi,
I’m wondering as you’re targeting separate pages
but here is the stranded code for every page(taken from venture theme)
{%- assign og_title = page_title -%}
{%- assign og_url = canonical_url -%}
{%- assign og_type = 'website' -%}
{%- assign og_description = page_description | default: shop.description | default: shop.name -%}
{% if settings.share_image %}
{%- capture og_image_tags -%}{%- endcapture -%}
{%- capture og_image_secure_url_tags -%}{%- endcapture -%}
{% endif %}
{% comment %} Template specific overides {% endcomment %}
{% if request.page_type == 'product' %}
{%- assign og_title = product.title | strip_html -%}
{%- assign og_type = 'product' -%}
{% if product.images.size > 0 %}
{%- capture og_image_tags -%}{% for image in product.images limit:3 -%}{% endfor -%}{% endcapture -%}
{%- capture og_image_secure_url_tags -%}{% for image in product.images limit:3 -%}{% endfor -%}{% endcapture -%}
{% endif %}
{% elsif request.page_type == 'article' %}
{%- assign og_title = article.title | strip_html -%}
{%- assign og_type = 'article' -%}
{%- assign og_description = article.excerpt_or_content | strip_html -%}
{% if article.image %}
{%- capture og_image_tags -%}{%- endcapture -%}
{%- capture og_image_secure_url_tags -%}{%- endcapture -%}
{% endif %}
{% elsif request.page_type == 'collection' %}
{%- assign og_title = collection.title | strip_html -%}
{%- assign og_type = 'product.group' -%}
{% if collection.image %}
{%- capture og_image_tags -%}{%- endcapture -%}
{%- capture og_image_secure_url_tags -%}{%- endcapture -%}
{% endif %}
{% elsif request.page_type == 'password' %}
{%- assign og_title = shop.name -%}
{%- assign og_url = shop.url -%}
{%- assign og_description = shop.description | default: shop.name -%}
{% endif %}
{% if request.page_type == 'product' %}
{% assign current_variant = product.selected_or_first_available_variant %}
{% endif %}
{{ og_image_tags }}
{{ og_image_secure_url_tags }}
{% unless settings.social_twitter_link == blank %}
{% endunless %}