[英]How To Define Title And Description For Particular Tags In Shopify?
I am adding the title and description for the particular tags in theme.liquid but it is not coming properly.我正在为theme.liquid 中的特定标签添加标题和描述,但它没有正确出现。 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 like the collection title, so I want to show only my added title for the tag.我想为标签显示“喜马拉雅盐灯 SEO 标题”,但标题中还有其他内容,如集合标题,所以我只想显示我为标签添加的标题。
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 %}
{% unless collection.tags contains 'Himalayan Salt Lamp' %}
{%- assign meta_tags = current_tags | join: ', ' -%} – {{ 'general.meta.tags' | t: tags: meta_tags -}}
{% endunless %}
{%- 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 -%}
It is showing some title but it is also showing the collection title, so I don't want to show that.它显示了一些标题,但也显示了集合标题,所以我不想显示。
Any help is much appreciated.任何帮助深表感谢。
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 -%}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.