TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Best Structure for a Multilingual Website?

3 点作者 offsky大约 2 年前
I am planning to translate a static website into a few other languages. I am trying to figure out the best structure for doing this. I can think of 5 ways to do it. Example using Spanish:<p>1) es.example.com&#x2F;index.html<p>2) www.example.es&#x2F;index.html<p>3) www.example.com&#x2F;es&#x2F;index.html<p>4) www.example.com&#x2F;index.html (with language set via a cookie)<p>5) www.example.com&#x2F;index.html?lang=es<p>I see a problem with #2 already because TLDs are country specific not language specific. Also expensive.<p>I think #4 has a problem with regard to search engine optimizations as both languages would have the same canonical url. I would like my content to be indexed in both languages.<p>Wikipedia does #1. Apple does #3. Google does both #2 and #4.<p>Question 1) What structure would people here recommend?<p>Question 2) Would it be best to detect the browser&#x27;s preferred language and auto-redirect people, or should I make the user do that language choice manually?

2 条评论

necovek大约 2 年前
I think Apache web server supported setting Content-Language automatically and doing content negotiation based on Accept-Language (browser-set language) for static sites if you simply used index.es.html.<p>It&#x27;s been a long time since I used this, so check the specifics.
mytailorisrich大约 2 年前
I think #3 is the most elegant and generic, and you can still use TLDs in addition. It also works well for a static website.