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 HTML Basics Going Further with HTML Root-relative Paths

dala lin
seal-mask
.a{fill-rule:evenodd;}techdegree
dala lin
Front End Web Development Techdegree Student 390 Points

How to change root-relative path back to file path for my website on terminal

So i followed the instruction on Teacher's note and it works! But, how to I change it back to develop my website on my local hard drive instead of through web server?

1 Answer

Matthew Underhill
Matthew Underhill
20,361 Points

You have to change them all back to absolute paths manually as your computer does not see the root of your web directory as the actual root of your project.

The easiest way to avoid swapping them back is to use a web server MAMP/WAMP as you can set the project path in there so your computer then acts like a web server.

Once you start learning languages such as PHP, you will see how this can become much easier, because you can for example store your root paths as constants in one file and then require that file in every web page you make. That way if any directory/file is moved, you only have to change the constants once, all and all your sites links will be updated.

e.g in PHP

define("BASE_URL","/");
define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/");

Matt