
The basic building block of a website is the link, whether an internal link or an anchor-text link; zoom out to the entire internet beyond the site, and the reason the internet is called the internet is that it relies on links to interconnect every resource page. So when you normally use links, do you use absolute addresses or relative addresses? Do you know which kind of linking is more beneficial to SEO optimization?
1. What is an absolute path
Let's not make it so complicated—a simple example will do. You can tell from the name itself: an absolute address is absolute and will not change because of any environmental factor. For example, the address of this article is http://www.zhiliaonet.com/article/863.html, so the absolute address is this entire link.
2. What is a relative path
There is one thing to note about relative addresses: they can only exist within the site, and outside the site you cannot use this site's relative address. For example, the relative address of this page is /article/863.html. We can understand a relative address URL as the site's domain name removed, that is, the server name of the current service. Why do we say a relative address can only be used on its own site? Because when the program loads the link, for a relative address it will parse and visit server name + relative address; although what we see in the code is still a relative address, in essence it is the same as an absolute address. But if you put your site's relative address on another site, because the server name—that is, the domain name—is different, the address actually visited will be "the current domain name + the relative address," and the result, of course, is that it won't open.
3. Which kind of link is more suitable for SEO optimization
1. Optimization of absolute paths
Compared with relative address URLs, the biggest advantage of absolute addresses is high visiting accuracy, and they are unlikely to produce the problem of visit errors and dead links; a relative address, because the server name can change, may cause link errors due to program errors. In the end, a large number of inaccessible links will appear, which has an adverse effect on SEO. At the same time, if someone scrapes the website's content, you can let them take the real links along with it, which ultimately amounts to getting a backlink.
2. Advantages of relative addresses
They have very high portability: when the website's domain name changes, no dead links will appear; the domain name part of all the original links will change along with it, which saves a great deal of time and effort; and a website revamp will also become very convenient—this flexibility is something absolute addresses do not have. Even if your website doesn't change its domain name or get revamped, the access address and domain name of your test environment are certainly different too, and at that point absolute addresses will make operations rather troublesome when you test and go live.
4. How to combine the advantages of both
Only kids make choices—we adults of course want both. This problem actually isn't complicated: we use absolute addresses in our code, but what is shown on the front end needs to be absolute addresses. This is very simple; in fact we just need to define a global constant—for example, for this site the value of this constant can be "http://www.zhiliaonet.com". Then in all pages, wherever an address appears, we concatenate this constant + the relative address. So what the front end displays becomes an absolute address, but for us, if we need to change the domain name, we only need to change this constant, achieving the effect of modifying one place and synchronizing everywhere. In this way we get the advantages of both, and I believe this can still be of no small help for SEO optimization.
That is all the content of "Which is better for SEO optimization, absolute paths or relative paths?" It is only for webmasters to interact, exchange and learn from each other. SEO optimization is a process that requires persistence, and I hope we can all make progress together.

谷歌SEO