I'm coding HTML and I'm making a link to a title page. I have two ideas:
relative:<a href="/">
absolute, for example:<a href="http://www.example.com/">
(Assuming I work on www.example.com)
Which way is better? I guess absolute way is better for SEO, because you have links to your website. But maybe the absolute way is also slower, because the browser has to ask the DNS server and load the page completely again? Thank you!
Assuming the page is in the www.example.com domain and there is no <base href=...>
tag, the two constructs are completely equivalent.
It is the job of the browser to resolve the relative URL “/” to the absolute URL “http://www.example.com”. Search engine indexing robots do the same. All caching is based on the absolute URLs, so no difference there either.
There is the practical difference that if the pages are moved to another server, the relative URL can be retained whereas the absolute URL would need to be changed.
To illustrate why the difference does not matter, consider a case where there is a difference: href="/"
versus href="/index.html"
. Even though they may lead to the same page, the resolved absolute URLs are different strings. In caching they will be treated as different, and search engines will treat them as different, even though they may find out that the contents are identical (especially if one of them is HTTP redirected to the other). But what matters is the difference between the absolute URLs, not absolute vs. relative.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With