如何指定网站的语言?(HTML?)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1071789/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to specify language of website? (HTML?)
提问by chris
How do I specify that a page is in a certain language so search engines can understand?
如何指定页面使用某种语言以便搜索引擎能够理解?
Is it a meta tag I put at the top? If it is, do you know if most of the search engines use this to determine language?
它是我放在顶部的元标记吗?如果是,您是否知道是否大多数搜索引擎都使用它来确定语言?
I have converted 1 page of content in english to several different languages, and would like to include that information in the html/let the search engines know which language they are dealing with.
我已将 1 页英文内容转换为几种不同的语言,并希望将该信息包含在 html 中/让搜索引擎知道他们正在处理哪种语言。
回答by SingleNegationElimination
Quick google search gave me this: HTTP and meta for language. tl;dr
快速谷歌搜索给了我这个:HTTP and meta for language。tl;博士
<html lang="en">
There are other ways of specifying. If you are using apache, you can use a file extension for apache to pull the correct version based on the user-agent's given preferences. for example, name your index page index.html.en
, index.html.jp
, index.html.de
and so on...
还有其他指定方式。如果您使用的是 apache,您可以使用 apache 的文件扩展名来根据用户代理的给定首选项提取正确的版本。例如,命名你的索引页index.html.en
,index.html.jp
,index.html.de
等...
回答by Tres
Depending on your dtd:
取决于您的 dtd:
HTML:
HTML:
<html lang="en">
XHTML:
XHTML:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
If you are using a right to left language:
如果您使用从右到左的语言:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="he" lang="he" dir="rtl">
If using XHTML, you'll want to specify both the xml:lang and lang attributes. The xml:lang attribute takes precedence over lang.
如果使用 XHTML,您需要同时指定 xml:lang 和 lang 属性。xml:lang 属性优先于 lang。
回答by jitter
Check this page for a range of things you can do to try to get the search engine to pick up the right language.
查看此页面,了解您可以采取哪些措施来尝试让搜索引擎选择正确的语言。
How to Specify an HTML Web Document Language for good SEO
(In no particular order)
(排名不分先后)
- right domain suffix
- hosted in right county
- AddHeading syntax (Apache)
<meta http-equiv="Content-Language" content="yourlanguage" />
<html lang="yourlanguage">
for xhtml<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="yourlanguage" lang="yourlanguage">
<p lang="yourlanguage">
<meta http-equiv="content-type" content= "text/html; yourcharset">
- And search engines to text pattern analysis too (prefix/suffix of words, n-grams analysis)
- 正确的域名后缀
- 在正确的县举办
- AddHeading 语法 (Apache)
<meta http-equiv="Content-Language" content="yourlanguage" />
<html lang="yourlanguage">
为 xhtml<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="yourlanguage" lang="yourlanguage">
<p lang="yourlanguage">
<meta http-equiv="content-type" content= "text/html; yourcharset">
- 搜索引擎也可以进行文本模式分析(单词的前缀/后缀,n-grams 分析)