Example: Relative Links

Good Food Website Structure

Below is a diagram of the structure of the Good Food website. For the sake of this example, not all pages are included.

From index.html

Assume we are working in the root level index.html page.

Link to recipes.html: Answer
<a href="recipes.html">Recipes</a>
Link to mango.html: Answer
<a href="tips/mango.html">Mango</a>
Link to mango-chutney.html: Answer
<a href="recipes/mango-chutney.html">Mango Chutney</a>

From mango-chutney.html

Now assume we are working on the mango-chutney.html page.

Link to index.html: Answer
<a href="../index.html">Home</a>
Link to mango-salsa.html: Answer
<a href="mango-salsa.html">Mango Salsa</a>
Link to mango.html: Answer
<a href="../tips/mango.html">Mango</a>

We use ../ to move up one directory. When we link to mango.html, we must move up one directory, and then down in one directory to the tips folder.