简体   繁体   English

如何在 Shopify 中定义特定标签的标题和描述?

[英]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: ', ' -%} &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 -%}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 标题和描述标签中的口音 - Accents in the title and description tags 带有标题和描述标签的 SEO 和 Django - SEO and Django with title and description tags 如何在drupal中设置分类术语的元标记,以在描述元标记中显示相关节点的标题 - How to set taxonomy terms' meta tags in drupal, to display relevant nodes' title in the description meta tag 如何访问帖子的标签/标签,以便可以将其添加到页面的标题或说明中 - How do I access a posts's labels / tags so that I can add them to the page's TITLE or DESCRIPTION 如何在Shopify主题网站中添加元标签? - How to Add Meta tags in Shopify Theme Site? 是否建议动态更新Google meta标签? 如果通过ajax请求进行更新,则Google是否会更新诸如描述和标题之类的元标记? - Is it advisable to update google meta tags dynamically? Does google update meta tags like description and title if it is update via an ajax request? SeoBundle-未设置标题和描述 - SeoBundle - title and description are not set 如何更改Google搜索的外观,例如标题和说明? - How to change the google search appearance like the title and description? 使用 Javascript 获取元标题和描述 - Get meta title and description with Javascript Google SEO标题和元描述 - Google SEO Title & Meta Description
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM