html - 网页的a标签到底要不要写上域名?
怪我咯
怪我咯 2017-04-17 15:05:16
0
4
836

开发网页时,a标签的链接有两种写法,比如首页:

一种是<a href='/'></a>,使用者有vue官网,w3cschool,segmentfault等;
一种是<a href='www.xxx.com',使用者有美团,豆瓣等。

有说法是写上域名不容易被扒,且有利于seo,而不写则有利于更换域名,且有利于开发(少写代码)。到底哪个更好?更常用?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(4)
Peter_Zhu

Under normal circumstances, the domain name is not written. Not writing the domain name has no impact on SEO. As for the source code or data being stripped, the current crawler framework is very smart. They can strip it whether you write the domain name or not, even if there is a domain name. , batch replacement with various editors is also a matter of minutes.

For development, it is definitely more convenient not to write a domain name.

洪涛

Don’t write

  1. Doesn’t affect seo

  2. It doesn’t have much impact on crawlers. However, you still need to ban the IP when anti-crawling

  3. It is possible to change the domain name. Do you still have to change the entire code?

洪涛

For example, the server port in the development environment is 8080. If you want to write the domain name, it is . However, the port in the production environment is generally 80. At this time, it needs to be modified to. The code in the development environment and the production environment are inconsistent. If you do not write The domain name is the same in both development environment and production environment. There is no need to modify the code in different environments.

迷茫

The background is equipped with a domain name character,
for example:

    $path = "http://xxx.com"

It is stipulated that all URLs need to be added with $path,
In this way, you can instantly switch whether to prefix or not.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template