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 -%}
{{ seo_title | strip }}
{%- if page_description -%}
{%- endif -%}
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.
Hi @RaghavDev22 ,
I checked and there is a lot of information displayed. Refer https://i.imgur.com/wZ0Gelq.png
Hope it clear to you.
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.
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: ', ' -%} – {{ '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 -%}
{%- if page_description -%}
{%- endif -%}
@David_Weru , Thank you for the answer.
You’re welcome @RaghavDev22
If you mark the post as a solution, it will be easier for others to find it.