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

General Discussion

My friend has a server and wants to run my front end code for his website.

It looks great, but if I download it and then try to open it, no styles are applied. Is this because I need to change the root directory?

https://w.trhou.se/770w3bt2ap This is my snapshot, which works perfectly when I preview. How to run in on a local server?

If I want it to run on my local machine, how is it done? I removed the slash which should then work, but it isn't.

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

I don't know where you got the idea that it should work - rarely does anything just work :smile:

You need a local development environment. This is what is provided with workspaces and why it is a nice feature.

Check out the following courses - which ever apply to you - these are php which should work for you (if you're on mac or windows):

MAC Local Dev Environment

Windows Local Dev Environment

1 Answer

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

You just need to remove the "/" slash at the beginning of all your links so you use a relative path as opposed to a root relative path.

For example - remove the "/" before CSS in your stylesheet links:

    <link rel = "stylesheet" href = CSS/styles.css>
    <link rel = "stylesheet" href = CSS/normalize.css>

So then would I need to use the ../ operator? I’ll try this solution tomorrow and update.

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Nope don't need ../ to move up a level since your CSS and img directories are at the same level as index.html (your document root)

I removed all the slashes in front but it still won't apply any styles. Here is a snapshot: http://w.trhou.se/1lf365le5l When I open it, it opens in a browser with default html. What did I do wrong? Thanks in advance.

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

You say your friend has a server - what type of server are you installing on and what steps did you do to install?

He bought an ecc, but I coded the front end on treehouse's web server. It should work fine on any local machine, but when I download it and then run it from my local machine, it doesn't work.

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Not sure what an ecc is?

Why do you think it should work fine on any local machine (I don't think so)?

Pretty sure you need a web server like apache to serve your pages locally. I'm on Ubuntu and run it's LAMP stack and your pages load fine. I think you should look into an *AMP stack (WAMP, MAMP or XAMPP) depending on your OS.

Just let me know if you'd like more details.