Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

What is Best for Search Engines, Absolute or Relative URLs

         

engine

11:07 am on Oct 13, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month




This question still comes up these days, so it's a useful reminder.

What's the difference between absolute and relative URLs, and how a search engine crawls and indexes.

robzilla

4:03 pm on Oct 13, 2021 (gmt 0)

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



TLDW: there is no difference, they are treated equally because they translate to the same URL.

tangor

5:44 pm on Oct 13, 2021 (gmt 0)

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



Better question which is best for the coder?

Relative all the way!

lucy24

8:10 pm on Oct 13, 2021 (gmt 0)

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



which is best for the coder
I would have said, which is best for the site.

The choice is really between href="/path-from-root" and href="path-from-right-here".

It is very very unlikely that a full URL beginning in http is necessary or appropriate (and can sometimes break things like image display if there's an https mismatch). And the chances are pretty close to zero that href="../../etcetera" is ever, ever appropriate for a live* website.

* “Live” specified because I do use ../../ when previewing a new page locally, as it works whether or not I’m running MAMP.

brotherhood of LAN

8:29 pm on Oct 13, 2021 (gmt 0)

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



Always preferred relative simply because it's shorter and if you ever moved domain for whatever reason, the links won't matter.

I mean relative in the sense of beginning with a /, relative to the domain!

Guess it gets confusing when relative could mean "../" etc.

lucy24

12:07 am on Oct 14, 2021 (gmt 0)

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



relative could mean "../" etc.
And it could also mean "blahblah" with no leading slash--suitable for when you have a group of files that will always work as a package, like
/directory/
/directory/specificstyles.css
/directory/images/all-the-names-here

You might conceivably move the whole package to a different directory, but the immediate links will always keep the same relationship to each other.

brotherhood of LAN

1:32 am on Oct 14, 2021 (gmt 0)

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



suitable for when you have a group of files that will always work as a package, like


There's always baseurl to remove any problems either/or

[developer.mozilla.org...]

aristotle

10:25 pm on Oct 14, 2021 (gmt 0)

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



mean relative in the sense of beginning with a /, relative to the domain!


When I created my first site in 2004, the guide I used didn't show a slash, so I didn't either. Thus:

<a href="page1.html">Page 1</a>
<a href="page2.html">Page 2</a>
etc

But it worked anyway, and still does, since I've never changed it.

lucy24

11:31 pm on Oct 14, 2021 (gmt 0)

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



I hope that in the intervening 17 years you have learned what the leading slash means, and under what circumstances its presence or absence would make a difference.

aristotle

12:31 am on Oct 15, 2021 (gmt 0)

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



Well Lucy I know more now than I did then, but probably not as much as you :)