我在 中添加特定标签的标题和描述主题.液体 但它来不及。任何帮助深表感谢。
我想显示标签的“喜马拉雅盐灯 SEO 标题”,但标题中还有其他内容,例如集合标题,所以我只想显示我为标签添加的标题。
这是我的代码:
{%- 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 -%}
它显示了一些标题,但也显示了集合标题,所以我不想显示。任何帮助深表感谢。
最佳答案
这段代码应该给你这个标题。
{%- 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 -%}
关于seo - 如何在 Shopify 中定义特定标签的标题和描述?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68168721/