英文:
Craft CMS 4 multi language best practices
问题
大多数多语言网站在URL中显示区域设置。例如:https://www.stackoverflow.com/en。
但在Craft中,似乎存在一个问题,即默认语言似乎也可以在URL中不带有区域设置的情况下工作。这也导致了Google的索引问题。
我目前已经设置了两种语言,它们都有自己的基本URL,由相同的主机名组成,但以不同的区域设置结尾。
但是,Craft不会自动将用户从https://www.stackoverflow.com重定向到https://www.stackoverflow.com/en。尽管这是默认设置。
而且,https://www.stackoverflow.com/en/about 和 https://www.stackoverflow.com/about 似乎都是有效的URL。
如果我从默认语言的URL中删除区域设置,是否会更好?
这种设置方式有点奇怪,因为它将不会为所有语言提供一致的URL结构,但这可能会解决我的索引问题。
英文:
Most multi language sites show the locale in the URL. For example: https://www.stackoverflow.com/en.
With Craft the issue seems to be that the default language seems to also work without the locale in the URL. This is also causing indexing issues with Google.
I currently have languages setup and both have their own base URL which consists out of the same hostname but end with a different locale.
But Craft does not automatically redirect users from https://www.stackoverflow.com to https://www.stackoverflow.com/en. Even though this is the default.
And both https://www.stackoverflow.com/en/about and https://www.stackoverflow.com/about seem to be valid URL's.
Would it be better if I would remove the locale in the URL from the default language?
It's a little bit weird to have it setup this way since it will not have a consistent URL structure for all languages but it might fix my indexing issues.
答案1
得分: 1
我猜这很大程度上取决于用例。我对多语言网站的默认方法之一是以下之一:
- 使用 https://www.stackoverflow.com 作为默认语言,并提供通知或语言切换到其他语言,如 https://www.stackoverflow.com/nl
- 在 https://www.stackoverflow.com/en、https://www.stackoverflow.com/nl 等上提供所有语言,并编写一个根据浏览器语言重定向或回退到英语的重定向。
我更喜欢第一种方法,因为我认为不涉及重定向会更简单。复杂的解决方案往往容易出现故障,并以奇怪的方式引发问题。当我在旅行时浏览网页时,有时因为故障的重定向而无法访问某些内容。
我更喜欢一个明显的语言切换或通知,类似于苹果网站上显示的那种。
英文:
I guess it very much depends on the use case. My default approach to Multi-Language sites is one of the following:
- Use https://www.stackoverflow.com for the default language and offer a notice or language switch to the other languages like https://www.stackoverflow.com/nl
- Have all languages on https://www.stackoverflow.com/en, https://www.stackoverflow.com/nl, etc. and write a redirect that redirects according to browser language or falls back on english.
I prefer the first approach, as I assume it is just less complex to not have a redirect involved. Complex solutions tend to break and cause problems in weird ways. When I browse the web while travelling I sometimes cannot even access some content because of malfunctioning redirects.
I rather prefer a prominent language switch or notice, analog the one shown on the Apple website.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论