Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML HTML Basics Going Further with HTML Root-relative Paths

dala lin
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
18,680 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("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/");