HTML: Multiple language meta descriptions?

2019-02-06 21:08发布

问题:

How can I set two language meta descriptions to my website?

Is this code google valid?

<meta name="description" lang="en" content="english blablabla" />
<meta name="description" lang="hu" content="hungary blablabla" />

回答1:

Check this post from Google Webmaster Central Blog: http://googlewebmastercentral.blogspot.com.es/2010/03/working-with-multilingual-websites.html

"Google tries to determine the main languages of each one of your pages. You can help to make language recognition easier if you stick to only one language per page and avoid side-by-side translations. Although Google can recognize a page as being in more than one language, we recommend using the same language for all elements of a page: headers, sidebars, menus, etc. Keep in mind that Google ignores all code-level language information, from “lang” attributes to Document Type Definitions (DTD). Some web editing programs create these attributes automatically, and therefore they aren’t very reliable when trying to determine the language of a webpage."

Some info about multi languages websites:

Since html "lang" attribute doesn't allow define multiple languages, and meta attribute for specify language is obsolete, according to W3 recommendations, it's better to specify language in the HTTP header.

HTTP/1.1·200·OK
Date:·Sat,·23·Jul·2011·07:28:50·GMT
Server:·Apache/2
Content-Location:·qa-http-and-lang.en.php
Vary:·negotiate,accept-language,Accept-Encoding
TCN:·choice
P3P:·policyref="http://www.w3.org/2001/05/P3P/p3p.xml"
Connection:·close
Transfer-Encoding:·chunked
Content-Type:·text/html; charset=utf-8
Content-Language:·en

Like the meta element with the http-equiv attribute set to Content-Language, the value of the HTTP header can be a comma-separated list of language tags

See: http://tools.ietf.org/html/rfc2616#section-14.12

As RFC2616 says:

Multiple languages MAY be listed for content that is intended for
   multiple audiences. For example, a rendition of the "Treaty of
   Waitangi," presented simultaneously in the original Maori and English
   versions, would call for

       Content-Language: mi, en

If you go to http://validator.w3.org/check and try to validate this:

<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Language" content="en,hu">
<meta charset="UTF-8">
</head>
<body>
<p>Test</p>
</body>
</html>

W3 validator tool says:

Line 5, Column 52: Using the meta element to specify the document-wide default language is obsolete. Consider specifying the language on the root element instead.

Then, if lang attribute on html tag doens't allow multiple languages, I think your best try will be specify it in HTTP header



回答2:

The lang attribute may be placed on any element, not just the root html element or meta name="description". So you can write <html lang="en"><body>The Chinese translation of Stack Overflow is <span lang="zh-Hans">堆叠溢位</span></body></html> and it's good to put those lang attributes in because it helps visual browsers to choose the correct fonts and audio browsers for blind people to choose the correct voice.

Some non-Google search engines still want the obsolete <meta http-equiv="content-language"> markup (in particular Bing and Baidu reportedly still want these) but I have no idea if their implementations are standards-compliant enough to cope with two or more languages listed in http-equiv="content-language" (try it and see).

As for whether search engines will honour multiple instances of meta name="description" in multiple languages (with appropriate lang attributes), that depends on the search engine. Google have indicated they don't like side-by-side translations, which is a pity for those of us discussing foreign languages.