为了账号安全,请及时绑定邮箱和手机立即绑定

如何阻止 Shopify 截断 <title></title> 中的页面标题?

如何阻止 Shopify 截断 <title></title> 中的页面标题?

当年话下 2023-10-04 14:16:53
<title></title>我有几家商店,我注意到 Shopify 似乎会在附加商店名称之前自动截断 中长度超过 65 或 70 的产品标题。例如这个产品页面。页面标题变为:<title>Boho Beach Lace Cap Sleeves Ivory Chiffon Wedding Flower Girl Dress wi - Flower Girl Dresses</title>虽然应该是:<title>Boho Beach Lace Cap Sleeves Ivory Chiffon Wedding Flower Girl Dress with Pink Lining - Flower Girl Dresses</title>我知道谷歌不关心标题长度超过一定数量的字符,例如 65 或 70,但仍然保留整个关键字也没有什么坏处。例如,在这种情况下,如果人们搜索“粉红色”,标题中包含“粉红色”关键字仍然很有帮助。我认为最好保留标题而不截断它。那么如何防止 Shopify 截断标题呢?我只能在 theme.liquid 中看到这个:<title>{{ page_title }}{% 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 %}{% unless page_title contains shop.name %} - {{ shop.name }}{% endunless %}</title>我不知道我应该修改哪里才能实现这一点?
查看完整描述

1 回答

?
泛舟湖上清波郎朗

TA贡献1818条经验 获得超3个赞

我不相信它在前端 Liquid 中被截断。您看到的输出是page_title而非product.title. 前者来自产品管理页面底部的“SEO”部分。默认情况下,该字段是product.title.


你可以做的是这样的:


{% assign desiredTitle = page_title %}

{% if template == 'product' %}

  {% assign desiredTitle = product.title %}

{% endif %}

<title>

  {{ desiredTitle }} // etc. etc.

</title>


查看完整回答
反对 回复 2023-10-04
  • 1 回答
  • 0 关注
  • 96 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信