Link types, full and non-full address

Are there any differences between the links

<a href="http://site.com/article-page">Статья</a>
или
<a href="/article-page">Статья</a>

I.e. how is it better to specify ? for I call the full path in all references, instead of how do I understand the inner one ?

Author: webstackoverload, 2017-07-30

4 answers

There is no difference for your site visitors. The difference occurs in the following cases:

  1. You decide to change the site domain.
  2. You decide to change the protocol from HTTP to HTTPS.

In this case, you will need to update all the links on the site. If you have static pages or content with static absolute links, then there is a problem: you will need to update all the links on the entire site. This is fraught with errors, for example, if you skip some link, then the navigation will break down and the user will not find the page they need.

If you generate links programmatically, for example, you have a constant "site domain" and you output it every time, and not just copy the full address, then again there are no problems - you just need to change one link. Among other things, this approach allows you to place the site in a subfolder (links like /page will be placed in the root).

Using the same different types of relative paths (/page, page, //domain/page) - this is a method that it works when changing the domain and protocol regardless of the technology used, so it is usually preferred.

 2
Author: Kyubey, 2017-07-30 15:44:56

If this is a link to one of the pages of the site you are working on, then the second option is better.

The first option is absolute, the second is relative. If you specify an absolute path, and the site, for example, moves to another domain, the link will already be inactive. And if you just specify href=" / article-page", then everything will work

 2
Author: Kate, 2017-07-30 15:38:43

I will add from the point of view of optimization for search engines, the 1st option as a full-fledged link will be better to pass the reference, otherwise Squidward is right, so to summarize, I would put the site host with the protocol in the variable ("http://site.ru") and I would generate links with this variable in mind, if the site engine allows it of course).

 1
Author: Providec, 2017-07-30 18:49:36

It all depends on where your article is located and your html file itself, if you have the article itself from someone else's source, then you need to write the full address(http://site.com/article-page), if you have it (for example, in the same folder where the htmlfile is) , then you can just write the name of the file,(or if not in the same folder, then write the address of the article referring to the position of the htmlfile in the system)

 0
Author: Andrei Gospodarenco, 2017-07-30 16:16:14