有没有办法在shopify中对子文件夹实施hreflang

发布于 2025-02-06 09:21:42 字数 550 浏览 1 评论 0原文

Here my current custom code in shopify. 

<link rel="alternate" hreflang="en-au" href="{{ canonical_url | replace: 'us', 'au' }}"  />

输出通过源代码如上所述,

<link rel="alternate" hreflang="en-au" href="/en-au/pages/faqs"  />

上面代码的问题是,当访问者在UK等其他国家 /地区查看它时,它不会 /en-uk在URL中。我正在尝试使其更加动态,以便我可以在其他国家 /地区实施。这是我尝试过的代码,但在Shopify中显示出错误的错误

<link rel="alternate" hreflang="en-au" href="{{ canonical_url | replace: '{{ localization.country.iso_code }}', 'au' }}"  />
Here my current custom code in shopify. 

<link rel="alternate" hreflang="en-au" href="{{ canonical_url | replace: 'us', 'au' }}"  />

the output goes like this via source code

<link rel="alternate" hreflang="en-au" href="/en-au/pages/faqs"  />

The problem with the code above is that when visitors view it in other country like UK it won't /en-uk in the URL. I am trying to get to make it more dynamic after /en- so that I can implement on other countries. Here is the code I've tried but it gets error showing "liquid error" in Shopify

<link rel="alternate" hreflang="en-au" href="{{ canonical_url | replace: '{{ localization.country.iso_code }}', 'au' }}"  />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与往事干杯 2025-02-13 09:21:43

如果您认为您的最后一部分会起作用,则只需在变量中提取第二个液体代码即可使用它。
这是我的意思:

而不是

<link rel="alternate" hreflang="en-au" href="{{ canonical_url | replace: '{{ localization.country.iso_code }}', 'au' }}"  />

喜欢

{% assign iso_code = localization.country.iso_code %}
<link rel="alternate" hreflang="en-au" href="{{ canonical_url | replace: iso_code, 'au' }}"  />

If you think that your last part will work, you simply have to extract the second liquid code in a variable and use it.
Here is what I mean:

Instead of

<link rel="alternate" hreflang="en-au" href="{{ canonical_url | replace: '{{ localization.country.iso_code }}', 'au' }}"  />

do like

{% assign iso_code = localization.country.iso_code %}
<link rel="alternate" hreflang="en-au" href="{{ canonical_url | replace: iso_code, 'au' }}"  />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文