How To Define Title And Description For Particular Tags?

Solved
RaghavDev22
Tourist
8 0 1

I am adding the title and description for the particular tags in theme.liquid but it is not coming properly. Any help is much appreciated.

I want to show the "Himalayan Salt Lamp SEO Title" for the tag but other things are coming in the title.

This is my code:

{%- capture seo_title -%}

{%- if request.page_type == 'search' and search.performed == true -%}
{{ 'general.search.heading' | t: count: search.results_count }}: {{ 'general.search.results_with_count' | t: terms: search.terms, count: search.results_count }}
{%- else -%}
{{ page_title }}
{%- endif -%}

{% if current_tags contains 'Himalayan Salt Lamp' %}
Himalayan Salt Lamp SEO Title
{% endif %}
{%- if current_tags -%}
{%- assign meta_tags = current_tags | join: ', ' -%} – {{ 'general.meta.tags' | t: tags: meta_tags -}}
{%- endif -%}

{%- if current_page != 1 -%}
– {{ 'general.meta.page' | t: page: current_page }}
{%- endif -%}
{%- assign escaped_page_title = page_title | escape -%}
{%- unless escaped_page_title contains shop.name -%}
– {{ shop.name }}
{%- endunless -%}
{%- endcapture -%}

<title>{{ seo_title | strip }} </title>

{%- if page_description -%}
<meta name="description" content="{{ page_description | escape }}">
{%- endif -%}

0 Likes
David_Weru
Trailblazer
129 9 21

Hello RaghavDev22!

 

Your capture tag needs an endcapture tag.

 

Anything between the tags is added to the variable.

{% capture my_variable %}I am being captured.{% endcapture %}

{{ my_variable }} 

 

 

If you'd like further assistance, please message me.

0 Likes
LitExtension
Shopify Partner
1228 156 217

Hi @RaghavDev22

I checked and there is a lot of information displayed. Refer https://i.imgur.com/wZ0Gelq.png

Hope it clear to you.

LitExtension - Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
0 Likes
RaghavDev22
Tourist
8 0 1

Yes, @LitExtension and @David_Weru I know that but It is also showing the other things in the title also. So, I want to show only my enter title for the particular tag. So, can you please suggest the code or solution.

0 Likes
David_Weru
Trailblazer
129 9 21

This is an accepted solution.

This code should give you just that title.

 

{%- if request.page_type == 'search' and search.performed == true -%}
{{ 'general.search.heading' | t: count: search.results_count }}: {{ 'general.search.results_with_count' | t: terms: search.terms, count: search.results_count }}
{%- else -%}
{{ page_title }}
{%- endif -%} 

{% if current_tags contains 'Himalayan Salt Lamp' %}


{%- capture seo_title -%}
Himalayan Salt Lamp SEO Title
{%- endcapture -%}


{% endif %}
{%- if current_tags -%}
{%- assign meta_tags = current_tags | join: ', ' -%} &ndash; {{ 'general.meta.tags' | t: tags: meta_tags -}}
{%- endif -%} 

{%- if current_page != 1 -%}
&ndash; {{ 'general.meta.page' | t: page: current_page }}
{%- endif -%}
{%- assign escaped_page_title = page_title | escape -%}
{%- unless escaped_page_title contains shop.name -%}
&ndash; {{ shop.name }}
{%- endunless -%}


<title>{{ seo_title | strip }} </title> 

{%- if page_description -%}
<meta name="description" content="{{ page_description | escape }}">
{%- endif -%}

 

 

RaghavDev22
Tourist
8 0 1

@David_Weru , Thank you for the answer.

David_Weru
Trailblazer
129 9 21

You're welcome @RaghavDev22 

If you mark the post as a solution, it will be easier for others to find it.

0 Likes