Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What href in link to title page? [closed]

I'm coding HTML and I'm making a link to a title page. I have two ideas:

  1. relative:
    <a href="/">

  2. 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!

like image 800
matlos Avatar asked Nov 04 '22 12:11

matlos


1 Answers

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.

like image 196
Jukka K. Korpela Avatar answered Nov 16 '22 05:11

Jukka K. Korpela