Before talking about absolute and relative paths, it is important to understand what a URL is. On the Internet, this one is essential. But do you really know what it is when it comes to URLs? Our seo course in lahore feels happy to guide peoples.
The Uniform Resource Locator URL is the address of a single resource on the web. Contrary to what one might think, the URL does not only target HTML pages. CSS images and documents also have the right to a URL that is unique. It is important to give special care to editing its URLs. Indeed if you are mistaken in the path of a URL the resource will not be found. In the same way, if you delete a resource present on your website, but leave its URL it will no longer be able to point to the initial resource.
Some elements that make up the URL are mandatory and unavoidable. This is the case of the protocol and the domain name. Http: // or https: // is a protocol. It allows to indicate to the browser by which protocol it can retrieve the content. On the Internet, we find mostly HTTP and HTTPS protocols.
www.seoh.fr is a domain name. With this indication, the browser knows which web server to find the content to display.
Agency SEO: This is the path to the resource to display in the browser also called “Slug”.
Absolute or relative what difference?
Let’s now discuss the case of absolute URLs and relative URLs. The example we gave you earlier in the article is actually an absolute URL. This is the one most often encountered when browsing the Internet: the complete path to the resource is necessarily indicated. However, there are also so-called relative URLs. In a case like this, the relative path of the resource on the server is indicated. For this reason, we mainly use the relative URL to make internal links within a web page. The use of relative URLs is very convenient provided you have a tree structure well thought for its website. Indeed, you need to know the different folders, subfolders and files to link them correctly. The relative URL is used to indicate the path between the current page and the resource it targets in the same tree. It can also provide the path between the site root and the resource in the tree.
How to navigate when using relative URLs?
Take for example resource type PDF, this file is called “my-tutor-url.pdf”.
We have several cases
If my-url-url.pdf is in the same place as the current page, (the current page is the page you are working on), the PDF URL will simply be the file name:
If my-tuto-url.pdf is in a folder (directory) named “tuto-pdf” and at the same level as the page, we will write the URL in this form:
Tuto-pdf / my-tutor-url.pdf
If my-url-url.pdf is in a “technical” subfolder (subdirectory) of the same directory “tuto-pdf”: then we will write
Tutorial-pdf / technical / my-tutor-url.pdf
- If my-url-url.pdf is the parent directory of the current directory then /mon-tuto-url.pdf. If my-url-url.pdf is in a subdirectory named “technique”, a different folder but of the same level as the one in which the page that we are working is /technique/mon-tuto- url.pdf
- Regarding the syntax of URLs related to the root of the site: the rule is as follows:
- We start with a / (slash) and we write the complete path to the resource: / folder / technique / my -tuto-url.pdf
Well, finally, it’s simple, but we must know its tree.
So relative or absolute URL?
The use of a relative or absolute URL in your source code will not change anything for your users or robots; unless you make a mistake, in which case 404.
In practice, at least 2 cases, can favor the relative URL:
- Pre-production and
- The change of domain name.
In both cases, the relative URL will make the “link” with the new information. If you opt for absolute URLs, a small “mill” in database and / or in HTLM files will be necessary to change the root of your URL protocol + namedemaine + tld
One last tip on the URLS?
No relative URL on the canonicals.
It is a security measure, if you forgot to make your redirects, for example, Http to https, without 3www to 3www, at least with an absolute URL, no doubt, the addressing is sure.