.htm 与 .html ? 哪个文件扩展名命名更正确?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1163738/
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
.htm vs .html ? Which file extension naming is more correct?
提问by CannibalSmith
Which file extension should I choose for my HTML files? And why?
我应该为我的 HTML 文件选择哪个文件扩展名?为什么?
回答by joe
The short answer
简短的回答
There is none. They are exactly the same.
空无一人。它们完全一样。
The long answer
长答案
Both .htm and .html are exactly the same and will work in the same way. The choice is down to personal preference, provided you're consistent with your file naming you won't have a problem with either.
.htm 和 .html 是完全相同的,并且以相同的方式工作。选择取决于个人喜好,只要您与文件命名一致,您就不会遇到任何问题。
Depending on the configuration of the web server, one of the file types will take precedence over the other. This should not be an issue since it's unlikely that you'll have both index.htm and index.html sitting in the same folder.
根据 Web 服务器的配置,其中一种文件类型将优先于另一种文件类型。这应该不是问题,因为您不太可能将 index.htm 和 index.html 放在同一个文件夹中。
We always use the shorter .htm for our file names since file extensions are typically 3 characters long.
我们总是使用较短的 .htm 作为我们的文件名,因为文件扩展名通常是 3 个字符长。
AND MORE ON: http://www.sightspecific.com/~mosh/WWW_FAQ/ext.htmlor http://www.sightspecific.com/~mosh/WWW_FAQ/ext.htm
更多信息:http: //www.sightspecific.com/~mosh/WWW_FAQ/ext.html或http://www.sightspecific.com/~mosh/WWW_FAQ/ext.htm
I think I should add this part here:
There is one single slight difference between .htm and .html files. Consider a path in your server like: mydomain.com/myfolder. If you create an index.htmfile inside that folder and you open that like this:mydomain.com/myfolder/, it will goes crazy and spit out your files as it is in your server,
but if you create an index.htmlfile in there and open that directory in your browser, it will load that file.
I tested this on my VPS and found thisMaybe you could somehow set your server to load index.htm files by default, but I guess the .html file is the default file type for browsers to open in each directory.
我想我应该在这里添加这一部分:
.htm 和 .html 文件之间有一个细微的区别。考虑服务器中的路径,例如:mydomain.com/myfolder。如果您在该文件夹中创建一个index.htm文件并像这样打开它:mydomain.com/myfolder/,它会发疯并吐出您的文件,因为它在您的服务器中,
但是如果您创建一个index.html文件在那里并在浏览器中打开该目录,它将加载该文件。
我在我的 VPS 上测试了这个,发现这个也许你可以以某种方式设置你的服务器默认加载 index.htm 文件,但我猜 .html 文件是浏览器在每个目录中打开的默认文件类型。
回答by Fenton
Neither!
两者都不!
If you're asking; "what would a website visitor rather type, htm or html" - it's much better to give them a nice descriptive URL with no extension. If they get used to going to yoursite/contact.html and you change it to yoursite/contact.php you've broken that link. If you use yoursite/contact/ then there's no problem when you switch technology.
如果你问; “网站访问者更愿意输入什么,htm 或 html” - 给他们一个没有扩展名的很好的描述性 URL 会更好。如果他们习惯了访问 yoursite/contact.html 而您将其更改为 yoursite/contact.php,那么您就破坏了该链接。如果您使用 yoursite/contact/ 那么当您切换技术时没有问题。
回答by DanDan
.html always for new files. .htm is a throwback to dos days.
.html 总是用于新文件。.htm 是对 dos 时代的回归。
回答by Pavel Minaev
.html
- DOS has been dead for a long time. But it doesn't really make much difference in the end.
.html
- DOS 已经死了很长时间了。但最终并没有太大的区别。
回答by waqasahmed
Same thing.. makes no difference at all... htm was used in the days where only 3 letter extensions were common.
同样的事情.. 没有任何区别...... htm 用于只有 3 个字母扩展名的时代。
回答by xtofl
If you plan on putting the files on a machine supporting only 8.3 naming convention, you should limit the extension to 3 characters.
如果您计划将文件放在仅支持 8.3 命名约定的机器上,则应将扩展名限制为 3 个字符。
Otherwise, better choose the more descriptive .html version.
否则,最好选择更具描述性的 .html 版本。
回答by xtofl
I guess it's a little too late now however the only time it does make a difference is when you set up HTML signatures on MS Outlook (even 2010). It's just not able to handle .html extensions, only .htm
我想现在有点太晚了,但它唯一能产生影响的时间是当您在 MS Outlook(甚至 2010)上设置 HTML 签名时。它只是无法处理 .html 扩展名,只能处理 .htm
回答by Wadih M.
It's the same in terms of functionality and support. (most OS recognize both, most Search Engines recognize both)
在功能和支持方面也是如此。(大多数操作系统都识别,大多数搜索引擎都识别)
For my everyday use, I choose .htm because it's shorter to type by 25%.
对于我的日常使用,我选择 .htm 是因为它的输入时间缩短了 25%。
回答by T0xicCode
Since nowadays, computers support widely any length as file type, the choice is now only personal. Back in the early days of Windows where only 3 letters where supported, you had to use .htm, but not anymore.
由于如今,计算机广泛支持任何长度的文件类型,因此现在只能选择个人。在 Windows 的早期,仅支持 3 个字母,您必须使用 .htm,但现在不再使用了。
回答by TerryD
Here is some food for thought.
这是一些值得深思的食物。
If you had been using all .htm files on your website and now, for example, you have changed the editor that you are using, and your new editor is outputting all your files with the .html extension. When you re-publish your site to the server, it would seem to me that you could really hurt your SEO position/ranking as many of the links out there in the web, including Google, that were looking for the .htm and not the new .html for that same page. This assumes that you are still using the same page names from your old editor which would make sense.
例如,如果您一直在网站上使用所有 .htm 文件,而现在您已经更改了正在使用的编辑器,并且您的新编辑器将输出所有扩展名为 .html 的文件。当您将您的网站重新发布到服务器时,在我看来,您可能真的会损害您的 SEO 位置/排名,因为网络中的许多链接(包括 Google)都在寻找 .htm 而不是同一页面的新 .html。这假设您仍然使用旧编辑器中的相同页面名称,这很有意义。
Anyway... My point is, be careful not to loose that link juice you have build up. So I guess in this example, there is a reason to stick with .htm... But other then that as mentioned by everyone else they seem to be the same.
无论如何......我的意思是,小心不要失去你已经建立的链接汁。所以我想在这个例子中,有理由坚持使用 .htm...但除此之外,正如其他人提到的那样,它们似乎是一样的。
Please correct if I'm wrong.
如果我错了,请纠正。
The reason I mention all this is because this is what I was in the process of doing when it occurred to me I may be damaging the site SEO with the new editor.
我之所以提到这一切,是因为当我想到我可能会使用新编辑器破坏网站 SEO 时,这就是我正在做的事情。
The original editor was MS Front Page, which always outputted .htm, dead now, and the new editor "90 Second Web Builder 9" which outputs all .html files... Luckily, they must have thought about this and they included a way to change the output extension back to .htm
原来的编辑器是 MS Front Page,它总是输出 .htm,现在已经死了,而新的编辑器“90 Second Web Builder 9”输出所有 .html 文件......幸运的是,他们一定已经想到了这一点,他们提供了一个方法将输出扩展名改回 .htm
Anyway, that's my 2 cents... hope it helps someone..
无论如何,这是我的 2 美分...希望它可以帮助某人...