How to geotarget website with multiple languages but one link only?

六眼飞鱼酱① 提交于 2019-12-25 18:46:21

问题


I have a website with two languages, which works in this format:

example.com/changelanguage.xx?lang=de

and redirects to German language

and calling the same URL again like:

example.com/changelanguage.xx?lang=​en

redirects to English language.

The URL remains the same example.com after redirection, just the language changes.

How to add the hreflang attribute here (for Google indexing)?


回答1:


It’s a bad practice to use the same URL for different (i.e., translated) content.

Consumers, like search engine bots, would use rel-alternate + hreflang markup to find translations. For this to work, you have to provide a different URL for the translated page.

From the perspective of the search engine, it doesn’t work for their users if using the same URL: when they give http://example.com/foobar as search result, they want to make sure that their users get the language the search engine intended (e.g., someone searching for German terms should get the German page). But with your system, this doesn’t work; the search engine user might end up with the English version.

Instead, you should represent the language in the URL, e.g. the language code as first path segment:

http://example.com/en/contact
http://example.com/de/kontact

(Or use different domains/subdomains, or add a query parameter, etc. If you can make sure that translated pages would never have the same URL slug, you could even omit the language codes.)




回答2:


This is a year late but https://www.bablic.com/ do exactly this!

Furthermore they can automatically detect the language set in the user's browser and automatically show the user your website in that language!



来源:https://stackoverflow.com/questions/39117908/how-to-geotarget-website-with-multiple-languages-but-one-link-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!