Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

creating links between pages - why doesn't my link work?

So, I wanted to practice creating links in html. I created an index page in TextMate. And another page. I kept both files in the same folder. And I created a link from the index page to the other page. Then, I dragged the index file into my browser window. It showed up just fine.

But when I clicked on my link (and yes, it was coded correctly), it brought me to a page that said the webpage doesn't exist.

1) Why didn't my link work?

2) After I create my html files in an html editor, how do I open them up in a browser other then dragging them one by one from the program into the browser? I know how to open up one page - by saving it on my desktop or dragging it from my text editor into the browser. But when the index page is connected to other pages, my links in the index page don't work. And the other pages can't be accessed.

In a nutshell, how do I open up html files in my browser so they remain connected to the other files and all the links and everything else works?

Newbie,

Kristina

2 Answers

Glad to hear!

I put them inside of a folder.

In your case, I might just make a folder called "web" on my desktop, and store them inside of that. Something short, sweet, and easy to remember.

Later, after you get a bit more familiar with everything, I would install hosting software on your computer. It will make developing and launching actual sites much more easier. This is how I do it. On my work PC I use XAMPP and on my personal Mac I use MAMP.

Both do basically the same thing. They install Apache, which is a server software, among some other nifty things like MySQL which is a database.

When you install one of those software programs, in the files it installs one is called htdocs. This is where apache will look for web files. So when I turn on Apache, and I open up one of my web browsers, and simply type in the word "localhost" and the index file inside of the htdocs file will display in the browser.

But for today, I would just practice how you are. Make a folder, keep it somewhere easy to get to like the desktop, and just keep practicing. If you stick with it, and later feel more comfortable, jump into installing local server software. It'll eventually make your life much easier.

Thanks Kevin. Your response was VERY helpful!!! Thank you.

You're welcome. Figured I'd give you a good road map when you're ready for the next step.

When you feel like you are ready to use a software package like MAMP, WAMP or XAMPP, just post up and I'm sure you'll get some help.

It was very confusing for me when I first tried to install the software. It's actually not when you know what to do.

Once you start using, you won't know how you did without it! :) But today, you're okay doing what you are doing.

In general, if you have two files in the same folder, you can link from one to the other such as

href="filename.html"

as an example of using a HTML file. If it was a PHP file the extension would be .php.

In the other file, the href would need to link back to first file.

Does that help?

I finally figured out that the link wasn't working because I didn't have the html files on my desktop. One was in another folder. However, after one creates files in textmate (index.html, anotherpage.html, anotherpage2.html......., does one usually just save all the files on the desktop? Or do people usually put them all in a particular folder on their desktop? Or somewhere else?

Thanks for the feedback!