Welcome to WebmasterWorld Guest from 23.22.19.253

Forum Moderators: incrediBILL

Message Too Old, No Replies

What's the proper way to link to files? Need some help.

Linking correctly to files? Seen different types of links.Please help:)

   
7:22 am on Jul 23, 2005 (gmt 0)

10+ Year Member



Hi guys:)

I was wondering, what's the proper way to link to files?
>>**Only to files that i created for *my* site.<<

**Not to other websites.
**Other websites i know i need to us the http:// or www. for these outside links.

I ask because i've seen some websites use the link like this:

1.

<a href="file.html">File</a>

and others use this code:

2.

<a href="http://www.blahwidget.com/file.html">File</a>

and others use this code:

3.

<a href="www.blahwidget.com/file.html">File</a>

Well, please explain as i don't want to link the wrong way and not have it work. A little concerned.

Q.1. Which way should i link? Can i just use the first example for all links on my site? I'd like to use this for all my links.

>> <a href="file.html">File</a>

Well...Thanks for your help guys:)

frenzy77

9:21 am on Jul 23, 2005 (gmt 0)

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



Basic simple relative linking is best.

Some people think otherwise but I doubt many of them have done any programming. Search engines will treat all links identically. Why is that I hear you ask? Simply because all link information will be stored in a single normalised format. Whether the links appear on a page in relative or absolute form will make no difference.

So, to ensure easy maintenance (static html) and reduce page size, use relative urls. However, for dynamic pages, the issue of easy maintenance is blurred.

HOWEVER, www.domain.com may be treated as a separate url to domain.com

Kaled.

9:21 am on Jul 23, 2005 (gmt 0)

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



I'll keep it simple...

There are two TYPES of links, absolute and relative.

All absolute links start with "http://"
_______________________________________
"http://www.webmasterworld.com" is an absolute link.

Relative links start with either...
___________________________________

The file itself...
bob.html
... or ../ to go UP a directory to access a file.

If we're at http://www.example.com/1/2/3 and we want to link to...
http://www.example.com/1/bob.html we'd use...

<A href="../../bob.html" .....

///////////////////////

There are good and bad reasons to use both, you'll find out what your preference is sooner or later though.

Also you ~MUST~ use [....] This tells your computer to look on the internet. This would be the same thing if you asked me where the (closest) penguins are and I pointed north; assumming we're in like the US/Europe/etc and not in like umm, with our good mates in Aussie!

It's a love/hate feeling when I see people not use the http:// protocol in hyperlinks.

If you're on the page...
http://www.example.com/bob1.html

and you make a link of...
www.webmasterworld.com/bob.html

Your link will bring you to...
[webmasterworld.com...]

Hope this helps!

9:38 am on Jul 23, 2005 (gmt 0)

10+ Year Member



the first option is correct. Because we give virtual path.
11:52 am on Jul 23, 2005 (gmt 0)

10+ Year Member



Thanks guys for your help:)

Ok. So if i use absolute linking it would be placed like this for all files i link to.

>> <a href="http://www.widget.com/index.html">Home</a>

Q.1. >>Can i use this for all my links on my site?

Q.2. I don't know anything about directories so if my files are all in the same folder or area will it be ok to use the link:

<a href="http://www.widget.com/index.html">Home</a>

for a link to a file in the same folder such as a file
named index.html

Q.3. Would'nt i link to this with just the
<a href="index.html">link</a> since the file is in the same folder?

Q.4. What is wrong with useing the
<a href="widget.html">Link</a>

Q.5. Also if my files are all named like this:

index.html

abc.html

xyz.html

>>Q. When i upload them to my web space, will the domain that is set-up automatically attach the index.html file to the domain?

Like this:
[----.com...]

or do i have to do this somehow?

Q.6. >>>Also, will my host automatically set-up the domain as [-----.com...]

**(deleted name so it won't link.)

I ask because if i get inbound links i would like to receive the credit for the links with http:// or the www. (depending on how you have your link set-up.)

I've read that you only receive credit for one or the other.

Not sure how this all works.

**Please answer all questions:)
I really need some help as i'm new to placeing a site online.

ps. Is it ok if i sticky mail you if i need assistance with set-up of my website?

Thanks again guys:) Your very helpful:)

frenzy77

12:27 pm on Jul 23, 2005 (gmt 0)

10+ Year Member



Even though relative links are easily implemented, one of the ways to combat "302 hijacking" is to use absolute links even for internal pages of your website.

If prefer to use relative URLS make sure you have <base href="http://www.example.com/"> were its your domain of course, in the header of of each document.

4:49 pm on Jul 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If prefer to use relative URLS make sure you have <base href="http://www.example.com/"> were its your domain of course, in the header of of each document.

Can you expand on that thought?

2:15 am on Jul 24, 2005 (gmt 0)

10+ Year Member



Hey outrun:)_

Q.1. What's 302 hijacking? I'm not an expert like you guys:) I would like to just like to link up my pages safely so they work properly?

Q.2. Can i just use:
<a href="http://www.---.com/index.html">link</a>

for all my links and be protected?

Thanks guys for your help:)

Also, can you guys refer to my above questions and answer them as well? I really need your guys advice. I'm a newbie and i don't know as much as you guys yet.

Thanks guys:)

frenzy77

7:29 am on Jul 24, 2005 (gmt 0)

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



I don't like relative links like ../../../folder/filename.html

I prefer to always "count from the root" like: /folder/folder/filename.html instead.

.

When linking to an index file, do not include the index file filename in the link, end the link with trailing / only. Link to http://www.domain.com/ or / or /folder/ or http://www.domain.com/folder/ instead.

8:09 am on Jul 24, 2005 (gmt 0)

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



Unfortunately, this thread is trying to cover too many topics and that will make it pretty hard for future visitors to make use of. We prefer to have one question or topic per thread - that structure helps us to build a knowledge base that helps many people in the future, not just those who are in the thread today. So I'm going to enforce that idea by locking this thread now.

A number of your questions, frenzy77, can be found by using Google to search our site. For instance, enter site:webmasterworld.com 302 hijack and you will find MANY discussions about a pretty bewildering and frustrating topic. However, if you are just starting to learn HTML, it's probably just going to confuse things for you.

So I'd suggest you continue to ask questions about things you can't find answers for with a reasonable amount of searching - but one topic per thread, please. And don't forget that we have a forum dedicated to people who are New To Web Development [webmasterworld.com] -- you may find lots of answers in there.

In particular, as with every forum here, there is a Library linked at the top of every page in the New to the Web forum that holds some of the very best posts. There is one thread in particular that lists links to many other educational threads:

Valuable Reading for the New Webmaster [webmasterworld.com]