Absolute URLs vs relative URLs

Absolute URLs vs relative URLs

02.Oct.2021

An absolute URL is a complete web address, starting with "www" or not. For example: < http : //www.wikipedia.org/myarticle/>

A relative URL is one that does not start with "http://", but specifies where to find the requested page relative to the current document. For example, if you are reading myarticle.html , which is stored on your computer's hard drive at C:\myfiles\myarticles\myarticle.html , then the article might contain the following relative link within it to another file named otherfile.html stored in a subdirectory of the current directory: <a href= "../otherfiles/otherfile.html"> Click here to read about something else </a>

 

Absolute URLs vs relative URLs is part of the Webmaster Academy lesson on concepts and tools for understanding and using web addresses.

The content above should be rewritten because:

- It uses too much unreadable jargon without explaining it first, before using it. Reworded, the distinction between absolute and relative URLs becomes easier to understand without an initial barrier to entry created by inaccessible terms such as "absolute" and "relative". Also, many users will not understand what a URL is or does without some explanation.  - The article fails to explain why use one over the other in most cases when linking pages together (for example, when you want one page's address to change whenever another linked page changes). The choices, when choosing between absolute and relative URLs, should be explained in an article like this. - It doesn't explain how to know when one is needed over the other. If both concepts are explained in the article [and not just whether or not they are needed], then that explanation should provide some guidance about knowing which situation calls for an absolute/relative URL vs non-URL link.

- The end of the content ascribes a result to readers of using one over the other without properly explaining why that is part of the concept of relative versus absolute URLs. Instead, users might be left wondering more about what "relative" means and why it would matter if you use it instead of an "absolute" URL.

- Finally, the article has no references for its claims, leaving readers who want to verify what it says without any way of doing so.

- The article shouldn't be formatted as a question with incorrect answers. It shouldn't ask "What are absolute URLs?" if it doesn't explain the concept before asking the question, and certainly shouldn't give an incorrect explanation like "absolute URLs are necessary when you want your URL to change whenever the webpage linked to changes." They're necessary in many cases where you link between webpages, but there are also many cases where they aren't. The content needs rewriting from scratch [not just tweaking] in order to clear up this absolute/relative URL confusion.

Rewritten: What is a URL?

A web address is the location of a website or page on the internet. Web addresses start with either "http://", "https://", or in rare cases, "www" [which are called absolute URLs ]. If you wanted to go to Wikipedia's home page, for example, you would type https://en.wikipedia.org/wiki/Main_Page into your browser's address bar [or click here to go there directly].  

The rest of the URL after the host name at the very beginning identifies what content is located where on the site. For instance, if you were reading an article about hamsters and clicked on a link that took you to another page entitled "Hamster Colors," then both of those pages would have the same URL because they are on the same site. However, if you were reading about hamsters and clicked on a link that took you to http://www.Petco.com , then their pages wouldn't share an address [URL] because the latter is not part of Wikipedia's website.

Absolute URLs are necessary when you want your web address to change whenever the webpage linked to changes. Otherwise, links between static webpages wouldn't work properly or be able to keep track of each other because they'd refer to files by their old contents! For example, imagine that you're writing about birds in an article and wanted your readers to be able to click on a link for more information about cardinals :

The Northern Cardinal is a popular North American songbird. You can learn more about it [link to the Wikipedia article] by clicking on this sentence.

If you were using an absolute URL, then that link would always go to the same location even if someone changed or deleted the cardinals link in your article. On the other hand, if you used a relative URL for the Cardinals' Wikipedia page, then your link's destination would change whenever someone edited or removed content at https://en.wikipedia.org/wiki/Northern_cardinal , making links within pages break whenever that happened!

Relative URLs are necessary when you want your web address to remain unchanged regardless of where it links to on a site. Otherwise, links within static webpages wouldn't work properly or be able to keep track of each other. Imagine that you were writing about birds in an article and wanted your readers to be able to click on a link for more information about cardinals :

The Northern Cardinal is a popular North American songbird. You can learn more about it [link to the Wikipedia article] by clicking on this sentence.

If you used an absolute URL, then that link would always go to the same location even if someone changed or deleted content at https://en.wikipedia.org/wiki/Northern_cardinal . This means that whenever the linked page was updated with new information, your own article would break and any links within it would point to nonexistent pages! On the other hand, if you used a relative URL for the Cardinals' Wikipedia page, then your link's destination would remain unchanged regardless of where it links to on that site, making all of your hyperlinks work properly.

We are social