Best practice for URLs of multi-language websites

前端 未结 3 2007
花落未央
花落未央 2021-01-17 11:58

What is considered the best strategy for URLs of translated websites? Something I see happen frequently is:

http://example.com/english-slug.html
http://examp         


        
3条回答
  •  逝去的感伤
    2021-01-17 12:40

    I think you should use language tags and translated slugs:

    http://example.com/en/hello-world
    http://example.com/de/hallo-welt
    

    Why language tags? To avoid collisions.
    Sometimes you might want to have the same slug for different languages (for example, "team" in English as well as in German).

    Why translated paths? For better usability.
    Not all users understand the "default" language, and depending on its script, they might not even be able to type/remember/dictate the slug. (It doesn’t make sense in the first place to use human-readable slugs that only part of your users are able to understand.)

    Yes, it would be a "(minor) advantage that a user can manually switch to another language by modifying the URL". But it’s unlikely that users or search engines would expect this to work (see my related answer on Webmasters). So you would gain little (URL hacking for advanced users) and lose much (bad usability for users using the non-default language).

    That said, it would still be possible to enable this URL hacking feature in most cases: When users change the language tag de (in /de/hallo-welt) to en (/en/hallo-welt), you could check if it exists (if yes, show it), and if not, check if there exists a slug "hallo-welt" in any language, find its English translation and redirect to it (from /en/hallo-welt to /en/hello-world).

提交回复
热议问题