Welcome to WebmasterWorld Guest from 23.20.37.222

Message Too Old, No Replies

Relative or absolute internal links

     
8:25 am on May 13, 2012 (gmt 0)



For Google Panda, is it better to use relative or absolute internal links ?
12:34 pm on May 13, 2012 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Panda doesn't really enter into it, as far as I can see. However, I find that using root-relative links (those that begin with a forward slash) plus accurate canonical meta tags (where the href attribute includes the domain name) is an approach that offers the most accidental trouble and doesn't bloat the size of the source code.
2:00 pm on May 13, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I concur. Begin all links like href="/thisfile" with a leading slash.

Especially avoid the href="thatfile" and href="../otherfile" formats.

The reasons for not using the last two formats become painfully obvious once you start using "friendly URLs" and "URL rewriting".
12:01 am on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



an approach that offers the most accidental trouble

?
12:16 am on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



One small accident with an unintended relative link combined with a sloppy RewriteRule pattern beginning (.*)/ can lead to infinite duplicate content.
12:19 am on May 14, 2012 (gmt 0)

10+ Year Member



an approach that offers the most accidental trouble

Confused me as well.
10:19 am on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



For Google Panda, is it better to use relative or absolute internal links ?

Depends on your site really and how you want each page to be accessed. You may have to use absolute ones if you want certain pages to be accessed in https and others in http. Relatives won't work well.

Another issue is with content management. If you manage the site via an admin folder and want to preview some content within the folder, the relative paths may point to the wrong path, using absolute paths prevents these problems.

I am not 100% sure how googlebot views identical links exposed in different modes and depends on the configuration. To be on a safe side in these cases I will use absolute internal links. And keep an eye on the configuration vs what the bot indexes. There are various mistakes that can cause undesirable effects.
[webmasterworld.com...]
What you read there it's because of relative paths.
11:13 am on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you use all absolute urls on your site including the host name: http://www.example.com/link.html then the repetitions of "http://www.example.com/" on a couple hundred links on the page can really add up to increasing your page size unnecessarily.
11:18 am on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Yes, and you'll also get "mixed security" warnings on https pages when using images that are common to both sides.

The solution is to use URLs that begin with a slash and show the full path to the file. These are "relative to the root" and therefore "absolute within the site".
2:50 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I concur. Begin all links like href="/thisfile" with a leading slash.


@g1smd,

I am trying to figure out, if I had a domain [buildgreatwidets.tld...] and wanted to link to [buildgreatwidgets.tld...] would it be href="/blue.html"

Also, I read somewhere that it is good to use absolute links such as [buildgreatwidgets.tld...] when linking from [buildgreatwidets.tld...] because that way if [buildgreatwidets.tld...] is published somewhere, there will be a link going back to [buildgreatwidgets.tld...] and it is acknowledged whose content it is.

Can the same be accomplished by the way you are saying to link from one page to another?

And would I be able to link from one page to another the way that you are saying if using a website builder?

I appreciate your help.
3:00 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member netmeg is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



If you are linking between two entirely different domains, then you need to put the absolute address in. Relative links won't work.
3:06 pm on May 14, 2012 (gmt 0)



an approach that offers the most accidental trouble = means less mistakes when creating new pages etc. you always have to know how many levels down you go ../../ etc whereas if it is just /folder/page.html you have less chance of making a mistake.
3:12 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



If you are linking between two entirely different domains, then you need to put the absolute address in. Relative links won't work.


In the example that I mentioned, I am linking within the same domain (internal links).
4:37 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



In the example that I mentioned, I am linking within the same domain

... and that's why everyone keeps telling you to use example.com

http://www.example.com/link.html
vs.
[domain.com...]

:: twiddling thumbs ::

That being said: I still use relative links for most images and stylesheets. Why? Because my pages come in packages. If I move the package, the images will move right along with the pages and will remain in the same relative location, even if they're not in the same absolute location.
4:56 pm on May 14, 2012 (gmt 0)

10+ Year Member



So let me get this right Lucy, You use /folder/page.htm
Not ../folder/page.htm
5:00 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member crobb305 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



this has become a confusing thread, particularly since the linked examples do not work.
5:06 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Not trying to make things more confusing, but if linking to your home page from other pages on your site and/or the footer, is it better to use a trailing slash.

http://www.example.com/ instead of http://www.example.com
7:17 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Link to:
href="/"
for the home page
href="/thispage"
for a page in the root
href="/folder/thatpage"
for a page in a folder, and so on.

Banish the
../
notation from your links forever.
7:26 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Thanks.

I agree that root-relative links are a good way to go for internal links.

In some instances, when you may have to use an absolute url when linking to the home page, would you include a trailing slash in the href portion of the code?
7:37 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Yes, the root page of a site ends with "/".

It's either
href="/"
or
href="http://www.example.com/"
7:39 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



At the moment, I don't have the trailing slash in absolute links to my home page.

It has been that way for years. Would it be good to make the change and add the trailing slash?

In the SERP, when I look at the home page URL, a trailing slash is included (just wanted to mention this, not sure if it affects if I should make the change or not).
9:34 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I'd make the change just to be "right".
9:56 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When it comes to the home page of a domain, it is the one place in which the trailing slash doesn't matter too much.

http://example.com/
and
http://example.com
are the same url. There is no duplicate content issue.
When a web browser requests them, it has to send a request that looks like:
GET / HTTP/1.1
Host: example.com

This is different than
http://example.com/folder
and
http://example.com/folder/
in which the URLs could be configured to serve different content.

Having the slash on the end of the domain link makes it more like what the request that gets sent looks like and makes it seem more like the subdomain case. However it adds complexity (and one character to the url). I think it is a style issue more than a canonical/duplicate content issue. Its a similar issue as to whether or not the domain name is capitalized http://example.com vs http://example.com. It doesn't matter in terms of content.
10:46 pm on May 14, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



So let me get this right Lucy, You use /folder/page.htm
Not ../folder/page.htm

For links to other areas of the site I use /folder/page.html
For links within the same area I often use page.css or images/pic.jpg. I do have one area that uses ../motherpage.html because that's how the packages work.

:: avoiding eye contact with g1 ::

At the moment, I don't have the trailing slash in absolute links to my home page.

It has been that way for years. Would it be good to make the change and add the trailing slash?

In the SERP, when I look at the home page URL, a trailing slash is included (just wanted to mention this, not sure if it affects if I should make the change or not).

gouri, meet mod_dir. mod_dir, meet gouri. What you have there is the Directory Slash Redirect, which happens automatically with all real directories unless you've explicitly given orders to the contrary.

The home page is a special case. There, the browser itself sticks a slash / onto the end. So no matter what your link says, it will have a / by the time the request reaches your site.
2:01 am on May 15, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I appreciate the responses.

I was doing some research about absolute and relative urls, and I saw relative urls mentioned as href="blue.html"

Is this the same thing as href="/blue.html"

I am trying to determine if these are both ways of indicating root-relative links or is href="blue.html" something else?

@gs1md may have made mention to this early in the thread (post #4452876) but I am not certain that it is the same thing so I wanted to ask.

I have also read that if you use absolute urls and your domain name contains some keywords in it, that can help with rankings. There is more code when absolute urls are used, but I heard that the additional mentions of keywords in your code can be helpful.

Has anyone heard this?

Thanks.
4:21 am on May 15, 2012 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



is href="blue.html" something else?

That URL indicates a resource that's in in the current directory - the directory where the current URL exists. So if the current URL is in the root directory, then there's no difference. But if it is in a subdirectory, then it is VERY different.

I'd suggest you experiment on a local version of a website, using all kinds of configurations. This will help set the variations more firmly in your comprehension.
4:39 am on May 15, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



I was doing some research about absolute and relative urls, and I saw relative urls mentioned as href="blue.html"

Is this the same thing as href="/blue.html"

No. It may happen to yield the same page if you start out in your top-level directory, but the meanings are entirely different.

:: shuffling papers ::

[w3.org...]

Do not try to read it all in one sitting.
5:21 am on May 15, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



With a page relative link you would link to
http://www.example.com/folder/page2
as
href="page2"
from
http://www.example.com/folder/page1

href="folder/page2"
from
http://www.example.com/

href="../folder/page2"
from
http://www.example.com/otherfolder/page5


With a root relative link you would link to
http://www.example.com/folder/page2
as
href="/folder/page2"
with a leading slash from anywhere and everywhere on the same site.

The latter method is preferred and is the only viable solution if your site uses URL rewriting.
9:07 am on May 15, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Yes, and you'll also get "mixed security" warnings on https pages when using images that are common to both sides.

That's what happens when you ignore the connection method.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month