A relative URL is any URL that doesn’t explicitly specify the protocol (e.g., ” http:// ” or ” https:// “) and/or domain ( www.example.com ), which forces the visitor’s web browser (or the search engine bots) to assume it refers to the same site on which the URL appears.
Relative Link
A relative link, on the other hand, takes advantage of the fact that the server knows where the current document is. Thus, if we want to link to another document in the same directory, we don’t need to write out the full URL. All we need to use is the name of the file.
Relative Path vs Absolute Path:
Absolute paths contain a complete URL, which includes a protocol, the website’s domain name, and possibly a specific file, subfolder, or page name. For example A Folder
The URL here, http://domain.com/ourfolder, can be entered into a browser’s search bar, and we’ll be taken where we want to go. While our personal browser may let us omit the protocol, https://, we should always include the protocol when coding absolute links to make sure they work for all visitors.
Conversely, a relative link only includes the name of a specific file or page, which is relative, to the current path. If we keep all of our website’s files in a single directory, we can establish links between pages as follows:
The Homepage of my website
Relative URLs come in three flavors:
1. Path-Relative URLs
<a href=”services/video-production/corporate-videos”>
<a href=”corporate-videos”>
The URL begins with the name of a page, or the name of a path (folder, directory, whatever) containing a page. Browsers assume this link refers to a page that is either in the same directory as the page on which the link appears, or in a subdirectory below it.
For example, let’s say a site has a Services section, and under that have a subsection called Video Production, and that the overview page for this service has the URL:
http://example.com/services/video-production
<a href=”video-production”>
Having no domain or foreslashes, this link is assumed by browsers to be relative to the path of the page on which it appears, correctly calculating the absolute URL for this link as:
“http://example.com/services/video-production/”
This is a perfectly valid use for path-relative URLs.
2. Root-Relative URLs
Examples:
<a href=”/services/”>
<a href=”/services/video-production”>
The leading foreslash before “services” indicates that this URL is relative to the root of the site’s URL structure, rather than the path of the page on which it appears. In this case, the absolute URL is calculated to be:
“http://example.com”
+ “/services/video-production“
Root-relative URLs are probably the safest kind of relative URL overall, both for minimizing the potential for human error, and for simplifying site maintenance. When absolute URLs aren’t an option, root-relative URLs are probably best.
3. Protocol-Relative URLs
Examples:
<a href=”//services/”>
<a href=”//services/video-production”>
The double-leading-foreslash (“//”) tells the browser to use the same connection scheme or protocol (i.e., either HTTP or HTTPS) as used to request the page on which the URL appears, so if this URL is on a page whose URL begins “https://”, then protocol-relative URLs on that page should also begin with “https://”.
Screenshot before applying snippets of code:
Screenshot after applying snippets of code:
Excellent blog here! Also your website loads up very fast!
What you published made a lot of sense.
Right here is the perfect webpage for anybody who hopes to find out about this topic.
You understand so much its almost hard to argue with you (not that I personally will need to…HaHa).
You certainly put a fresh spin on a subject which has been discussed for decades.
Excellent stuff, just wonderful!
Good post. I learn something totally new and challenging on sites I stumbleupon every day.
I love looking at and I conceive this website got some genuinely utilitarian stuff on it! .
I was extremely pleased to discover this page. I want to to thank you for ones time due to this wonderful read!! I definitely appreciated every part of it and I have you bookmarked to look at new information on your web site.
Keep functioning ,impressive job!
Great article post. Really looking forward to read more. Want more.
Many thanks for sharing this great web site.
You’ve got superb info in this case.
I think this website contains some really great info for everyone.
Thank you for every other informative blog.
Major thanks for the article. Thanks Again. Keep writing.
Appreciate you sharing, great blog post. Fantastic.
Nice post. I learn something new and challenging on sites I stumbleupon on a daily basis. Its always helpful to read through articles from other writers and use something from their web sites.
I absolutely love your blog and find the majority of your post’s to be just what I’m looking for. Does one offer guest writers to write content for you personally? I wouldn’t mind publishing a post or elaborating on many of the subjects you write regarding here. Again, awesome weblog!
Thanks for the article post. Thanks Again. Fantastic.
You completed a number of good points there. I did a search on the theme and found a good number of persons will agree with your blog.
Great article! We are linking to this great article on our site. Keep up the good writing.
My brother recommended I would possibly like this website.
Layovers are CRAZY! Thanks for posting such an interesting place of refreshment. I am excited about my next coffee cup adventure.
Thanks for discussing the issues and covering them in a well written format.
Way cool! Some very valid points! I appreciate you writing this post and the rest of the site is also very good.
Thanks again for the blog article. Really looking forward to read more. Great.
I am actually pleased to read this web site posts which includes tons of valuable facts, thanks for providing such information.
Thank you for every other informative blog.
This is my first time pay a quick visit at here and i am really pleasant to read all at single place.
I am actually glad to read this website posts which carries plenty of useful information, thanks for providing these kinds of data.
Valuable information. Lucky me I found your website by accident, and I am shocked why this accident didn’t happened earlier! I bookmarked it.
Hello! I could have sworn I’ve been to this website before but after browsing through some of the post.
obviously like your web-site .
Thanks in favor of sharing such a pleasant opinion, piece.
I was curious if you ever thought of changing the structure of your site?
You made some good points there. I checked on the web for more information about the issue .
Greetings! Very useful advice in this particular article! It is the little changes that make the biggest changes. Many thanks for sharing!
Great blog!
Appreciate it! Quite a lot of knowledge.
Absolutely pent subject matter, Really enjoyed looking through.
thanks great site
thanks.
I appreciate your piece of work, regards for all the great blog posts.
I like this web blog very much, Its a really nice position to read and incur information.
You made a number of fine points there. I did a search on the topic and found the majority of persons will have the same opinion with your blog.
your site is very nice, but you need to pay more attention to the comments of the users.
your site is very nice.
This is very interesting business idea, I have learned alots and hoping to continue to read more business tips. Thanks Mr. Patrick. Kristofer Bottom
I got what you intend,saved to favorites, very decent web site. Tuan Cruzan
You need to be a part of a contest for one of the best websites on the web. Virgilio Granata
Spot on with this write-up, I truly think this website needs much more consideration. I all probably be again to read much more, thanks for that info. Bryant Kisamore
You made some good points there. I looked on the internet for the issue and found most guys will go along with with your blog. Heriberto Heep
Just wanna tell that this is very beneficial , Thanks for taking your time to write this. Marshall Guler
Appreciate you sharing, great blog post. Much thanks again. Much obliged. Sid Sabates
I love your blog.. very nice colors & theme. Did you create this website yourself or did you hire someone to do it for you? Plz answer back as I’m looking to create my own blog and would like to know where u got this from. thanks a lot
Everything is categorically way in taking into consideration a unquestionably certain tally of the challenges. It was agreed informative. Your website is certainly helpful. Many thanks for sharing!
Hi there, just became alert tօ your blog through Google,
and found that it is really informative. I am gߋnna watch out for brussels.
I’ll aрpreciatе if you cоntinue this in future.
Many people will bе benefited from your writing. Cһeers!
I have been exploring for a little for any high quality articles or blog posts on this kind of area . Exploring in Yahoo I at last stumbled upon this web site. Reading this info So i am happy to convey that I have a very good uncanny feeling I discovered exactly what I needed. I most certainly will make sure to don?t forget this site and give it a look regularly.
This design is spectacular! You definitely know how to keep a reader amused.
I was almost moved to start my own blog (well, almost…HaHa!) Great job.
I really loved what you had to say, and more than that, how you presented it.
Too cool!
Thank you for writing the article. I like the topic too.
Thanks for posting such an excellent article. It helped me a lot and I love the subject matter.
Thank you for your post. I liked reading it because it addressed my issue. It helped me a lot and I hope it will help others too.
Thanks for your help and for posting this. It’s been wonderful.
Thank you for writing such a great article. It helped me a lot and I love the subject.
First off I would like to say superb blog!
May I request more information on the subject? All of your articles are extremely useful to me. Thank you!
yes sure you can contact me on skype : suren.sharma41 or on mail : smartwebperfection@gmail.com
You’ve been terrific to me. Thank you!
You’ve been very helpful to me. Thank you!
Hi my friend! I want to say that this post is amazing, nice written and include almost all significant infos. I would like to see more posts like this.
Great blog here!
If some one needs expert view about blogging then i suggest him/her to pay a quick visit this blog, Keep up the nice job.
Very nice post. I just stumbled upon your weblog and wished to say that I have really enjoyed surfing around your blog posts. After all I’ll be subscribing to your feed and I hope you write again very soon!
I want to thank you for your assistance and this post. It’s been great.
Thank you for providing me with these article examples.
Hello there, simply become alert to your weblog via Google, and found that it is really informative. I will be grateful if you continue this in future. A lot of folks will be benefited out of your writing. Cheers!
you’ve got a fantastic blog here!
Dude these articles have been really helpful to me. They really helped me out.
You made some respectable points there. I regarded on the internet for the problem and found most people will go together with together with your website.
Thank you for writing about this topic. Your post really helped me and I hope it can help others too.
Thank you for your excellent articles.
Great web site. A lot of helpful info here. And certainly, thank you to your effort!
Youre so cool! I dont suppose Ive read anything like this before. So nice to seek out someone with some unique thoughts on this subject. Really thank you for starting this up. this web site is one thing that’s needed on the net, someone with somewhat originality. Useful job for bringing something new to the web!
Wow, wonderful blog layout! How long have you been blogging for ? you make blogging look easy. The overall look of your website is great, let alone the content!
Thanks for your thoughts.
I have been absent for a while, but now I remember why I used to love this website. Thank you, I will try and check back more often. How frequently you update your site?