Forum Moderators: open

Message Too Old, No Replies

Page Linking

Full URL or just ../index.html , /folder/page.html

         

ztaco

4:08 am on Sep 24, 2017 (gmt 0)

5+ Year Member Top Contributors Of The Month



I see some site source code with the full URL in there navigation. And then some like mine with ../file.html, or /folder/page.html. What is the best way and why use the full URL?

keyplyr

4:23 am on Sep 24, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There are some useful purposes to use absolute file paths and there are reasons to use relative paths. Both get you to the target, no difference.

Absolute:
• if crossing directories
• Third party HTTP connections
• Outgoing links

Relative:
• brevity
• reduces bytes
• convenience (changing protocols for example)

phranque

4:25 am on Sep 24, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



there isn't necessarily one correct answer except "it depends".

there have been many past discussions here on Relative vs Absolute Links [webmasterworld.com].
you should familiarize yourself with the general issues and then see how they apply to your specific situation.

Relative vs Absolute Links site:webmasterworld.com - Google Search [google.com]

phranque

4:33 am on Sep 24, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



if crossing directories
...
Outgoing links


links that cross directories could be root-relative and outgoing links could be protocol-relative, so technically not absolute (i.e. href="/other/directory/file.name" and "href="//www.example.com/...")


reduces bytes


not so much if you are serving gzip-compressed html responses.
see the discussion i linked to above...

keyplyr

5:02 am on Sep 24, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Certainly. You can probably always find exceptions to examples. My examples addressed the generality of the OP.

lucy24

5:57 am on Sep 24, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



some like mine with ../file.html

In general this is the least desirable approach. Once you start back-stepping ("../../../") it can be hard for you to keep track of and, well, it just looks messy. (I personally use this form only for local, in-preparation files, so the browser or HTML Preview can find the stylesheets it needs. Before uploading, everything changes to site-absolute beginning in / slash.)

Pure relative links like "file.html" or "images/file.jpg" can work very well, especially when you've got a group of files that will always stay together in a package.

Root-absolute links like "/directory/filename.html" also have their uses; they remain valid even when the linking page moves to a different part of the site.

Protocol-based links starting in // are only for sites that, for reasons of their own, use a pervasive mix of http and https pages. (Even then, they're only meaningful for robots preparing a shopping list. Human browsers won't change protocol unless you tell them to.)

Absolute-absolute links including protocol really have no place on the average site; save the http:// for external links.

keyplyr

6:56 am on Sep 24, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Absolute-absolute links including protocol really have no place on the average site; save the http:// for external links
Absolutely

graeme_p

11:17 am on Sep 24, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have have found scraped versions of my site that include the absolute links as they are, so they point back to my site.

That would also apply to protocol relative links.

phranque

11:22 am on Sep 24, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Absolute-absolute links including protocol really have no place on the average site; save the http:// for external links

Absolutely

if crossing directories

isn't this inconsistent?



ztaco you should really consult some of the foundation documents to understand the concepts:

Uniform Resource Identifiers (URI): Generic Syntax [ietf.org]
1.4. Hierarchical URI and Relative Forms
An absolute identifier refers to a resource independent of the context in which the identifier is used. In contrast, a relative identifier refers to a resource by describing the difference within a hierarchical namespace between the current context and an absolute identifier of the resource.


RFC 1808 - Relative Uniform Resource Locators [tools.ietf.org]

lucy24

7:40 pm on Sep 24, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



isn't this inconsistent?
The problem is that there isn't enough terminology to go around. The two words "relative" and "absolute" have to cover four different types of link. Is it "root-relative" or "root-absolute"?

I have have found scraped versions of my site that include the absolute links as they are, so they point back to my site.
Well, that's pretty funny. I guess it depends on how attractive your site is to inept robots. Bonus points if the scraper didn't bother to change your "canonical".

keyplyr

8:09 pm on Sep 24, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have have found scraped versions of my site that include the absolute links as they are, so they point back to my site.
Of course... that's how I usually find them :)

vanesadawson

11:32 am on Oct 12, 2017 (gmt 0)

5+ Year Member



Hi,

There are two type of URL path, 1. Absolute path, 2. relative path. Each of have its' own features and importance. I always prefer to write the relative path for some resources like images and stylesheet , javascript files. If we change the main directory of the website then there is no changes required for these. In the other hand, I may need to be changed.