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

标签 seo shopify

我在 中添加特定标签的标题和描述主题.液体 但它来不及。任何帮助深表感谢。
我想显示标签的“喜马拉雅盐灯 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: ', ' -%} &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 -%}

关于seo - 如何在 Shopify 中定义特定标签的标题和描述?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68168721/

相关文章:

seo - Google 搜索不显示我的收藏夹

html - Shopify/Liquid 找到 "-"并删除之前的内容

c# - Shopify C# HMAC SHA256 OAuth 验证

shopify 我需要检查当前页面是否是集合页面而不是单个产品页面

javascript - 使用 shopify npm 模块创建草稿订单的错误请求

使用动态内容搜索单个页面

asp.net-mvc - ASP.NET MVC SEO 友好 URL

.htaccess - 将链接重定向到正确的目录

url - 在 Joomla 上打开 SEO 友好的 URL 使所有导航显示主页

javascript - 是否有办法使用外部 Javascript/jquery 文件检测 Shopify 中的变体更改?