Liquid, JavaScript, themes, sales channels
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 -%}
Solved! Go to the solution
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: ', ' -%} – {{ '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 -%}
<title>{{ seo_title | strip }} </title>
{%- if page_description -%}
<meta name="description" content="{{ page_description | escape }}">
{%- 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 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: ', ' -%} – {{ '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 -%}
<title>{{ seo_title | strip }} </title>
{%- if page_description -%}
<meta name="description" content="{{ page_description | escape }}">
{%- endif -%}
You're welcome @RaghavDev22
If you mark the post as a solution, it will be easier for others to find it.
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024