书格前端

你是否应该在URL中使用www


你是否应该在URL中使用www

文章翻译自于Should you use “www” in your URL or not?,这篇文章是写于2016,该不该在你的网站URL中使用www? 现在来看对于网站的SEO而言,了解一下还是有帮助的,并且MDN上也链接了这篇文章。

正文:

这是一个有很长时间的问题: 使用www或者不使用www? 多年来,人们会被问到这两者的区别,哪个对SEO更好,或者是否有必要修改他们的网址。

没有什么可惊讶的,网络上充满了关于这个话题的观点。一方面,支持www的人争论说“使用www能为超出一台服务器时网站扩展带来的挑战做好准备”;另一方面,支持无www的人坚称“使用www是冗余的并浪费时间”。

然而我们可以两方都支持,我们的观点是其实这不是太影响(Google也同意!)。对于普通的博客或自由职业者或者甚至机构,使用www或者不使用,都是绝对零优势。也就是说,他们在技术上是有区别的,并且有一个非常好的理由说明你为什么不应该同时使用。

外表具有欺骗性

当前能够通过www和无www的URL来访问一个网站都是很普遍的。如果你访问我们的网站,例如,你可以输入”http://www.themezilla.com”,或者裸的版本,“themezilla.com”,不管哪一种,你都可以到达我们的主页。

现在,这些URL看起来可能相同,很多人会争论越相同越好,但他们不是的。事实上,他们是完全不同的网站,并且Google也是这么认为的。

为了捕获URL格式上的差异,有些人会设立不同地址但是内容相同的网站,但这只会让搜索引擎判罚为重复内容。一个更好的办法,是创建一个URL版本的301永久性重定向到另一个,而不是让你自己来竞争网页排名。(我们重定向所有themezilla.com流量到http://www.themezilla.com)

变得权威

“标准化”是一个很大的词,可能是或不是Google发明了一个流程适用于”当有多个可选项时选择最好的URL”。不管你决定使用哪个格式,最重要的是始终如一并帮助搜索引擎决定”权威版本”(代表你整个网站的最好版本)。

例如,不要让你的一半流量到http://www.yoursite.com和另一半到yoursite.com。相反,选择一个你喜欢的,并总是使用这个格式作为你的内部链接。这不仅仅是为了让搜索引擎保持简单,也会让Google认为这不是两个不同网站而形成网页排名和链接上的竞争。

作出你的选择

URL格式是个人的偏好,这里涉及我们前面间接提到的一些技术性差异,可能会影响到非常高流量的网站。

简单的说,当你使用无www或者说裸的域名,并且你拥有多个子域名,这会让服务器或云服务更新DNS记录变得困难。另一个裸域名相关的问题是操作cookies:没有www,cookies会发送到所有的子域名,减慢访问静态内容和影响缓存。

如果你完全听不懂,不用担心。这是针对每天百万页面访问量的极其大型网站相关的特定场景。

总结

对于我们的网站,我们默认使用www域名,因为我们对字母表末尾的字母情有独钟,并且这让我们自我感觉网站规模比目前更大。

但是你可能讨厌字母”w”,或者你更喜欢裸URL。这都是可以的。没有一个选择是明确优于另一个的,我们鼓励你作为你自己的网站管理员,来决定哪个是最好的。


这篇文章英文部分用词稍微有点晦涩,有翻译不到位的地方,可以结合原文进行理解。

英文原文

Should you use “www” in your URL or not?

It’s a question for the ages: to www or not to www? For years, people have been asking if there’s any difference between the two, which one (if any) is better for SEO, and whether or not they need to change their site address.

Not surprisingly, the internet is full of opinions on the topic. On one side, you have the yes-www’ers who argue that using www “makes you more prepared to handle the challenges of a growing website beyond a single server.” On the other, you have the no-www’ers who insist that using www is “redundant and time-consuming.”

While we can sympathize with both sides, our official opinion is that it doesn’t really matter (Google agrees!). For the average blogger or freelancer or even agency, there is absolutely zero advantage to using www or not. That said, there is a technical difference between the two, and there’s a very good reason why you shouldn’t be using both.

Appearances can be deceiving

It’s pretty common these days to be able to access a website from both the www and non-www version of its URL. If you want to visit our website, for example, you can type in “http://www.themezilla.com” or the “naked” version, “themezilla.com”—either way, you’ll end up on our homepage.

Now, these URLs may look similar—many would argue they’re as good as identical—but they’re not. In fact, they are completely separate sites, and Google treats them as such.

To capture variations in URL formatting, some people set up their site at a handful of similar but different addresses, only to be penalized by search engines for duplicate content. Instead of competing against yourself for page rankings, a much better approach is to set up a 301 permanent redirection from one version of the URL to the other (we redirect all themezilla.com traffic to http://www.themezilla.com).

Getting canonical

“Canonicalization” is a big word that Google may or may not have made up to refer to “the process of picking the best URL when there are several choices.” No matter which format you decide to use, the important thing is to be consistent and help search engines determine the “canonical version” (ie. the version that best represents your entire site).

For example, don’t send half your links to http://www.yoursite.com and the other half to yoursite.com. Instead, pick the URL you prefer and always use that format for your internal links. Not only does it keep things simple for search engines, it stops the page rank and link juice from getting divided between what Google thinks are two separate sites.

Picking your poison

While URL formatting is a matter of personal preference, there are a couple technical differences we alluded to earlier that might affect sites with very high traffic.

Basically, when you use a non-www or naked domain, and you also have several subdomains, it can become difficult for servers and cloud services to update DNS records. The other issue that can occur with naked domains has to do with cookies: without the www, the cookies get sent to all subdomains, slowing down access to static content and tripping up caching.

If this all sounds like Greek to you, don’t worry. These are highly specialized situations that really only affect extremely large websites receiving millions of page views per day. (We hear the chorus of yes-www’ers countering, “But who doesn’t want their site to get that large?”)

Summing up

For our site, we default to the www domain because we have a soft spot for end-of-alphabet characters, and because it makes us feel like we’re a part of something bigger than ourselves.

But you may hate the letter “w,” or you may just prefer your URL to be naked. And that’s okay! No one option is unequivocally better than the other, and we encourage you to be your own webmaster and decide which is best for you.