I lost everything I’ve just written… so lets try it again:
lets assume you’ve got this folder structure:
/index.html
/faq.html
/contact.html
/services/index.html
/services/service1.html
/services/service2.html
first, a couple of things regarding this:
- index.html should be your home, i.e. your main page. index.html is generally called automatically when you type in your domain, e.g. www.example.com will display the contents of index.html. You can change this but lets not go there.
- while not absolutely necessary, use lowercase for your filenames and don’t include any spaces, either write everything in one word or use - to separate words, e.g. experts-exchange
- every folder should have an index, as in 1. the index file will be normally called automatically when browsing to the folder, e.g. www.example.com/services/. So it would make sense to replace services.html with the index file of that folder. Links to that file then should be of the form:
<a href="/services/</a>Services</a>
the link won’t work if you’re trying this out on your local machine without having set up a local server (Xampp or Wamp - get either one of them and set them up, it’s not too difficult - in the case of Xampp, you then put all your files in the htdocs subfolder).
Back to your question, …/ should actually work to move one folder above, and the server will look for the index file. But again if you’re trying this out on your local machine this might not work. To call specific files, …/about.html should work.
However, I’d personally prefer to use the slash:
<a href="/">Home</a>
<a href="/about.php">About</a>
<a href="/services/">Services</a>
the slash tells the browser to start from root, so again this might not work on your local machine or if you’ve put the site in a subfolder on your local server, i.e. in htdocs/myproject. The advantage is that you don’t have to change the links in any of your files, regardless of how deep down the structure they are. Another advantage is that you now can put the menu code into a separate file and use php to include this one file in all your other files - you’d have to change the file extension to php and your local machine, without setting up a local server, won’t be able to display you those php files. The amount of php needed to achieve this is tiny:
<?php include '/includes/menu.php'; ?>
This line of code would go exactly where you’d have the html of the menu in your code.
For structural purposes I’d put such files in a separate folder, and just to keep it consistent would use the php file extension even if no php is in the actual file - it’s then just a simple html file but with the php extension. In this file, you only need the code for the menu, so no <html>, <head>, <body> etc., e.g.
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about.php">About</a></li>
<li><a href="/services/">Services</a></li>
</ul>