Hi I’m making a basic HTML website using Microsoft WebMatrix locally. When I’ve finished the website I will be uploading it to my web hosting.
Right now I’m using http://localhost:80/ to view my site and I’m using this sort of code…
<!--#include virtual="include/html/menu.html" -->
… to include the menu links so that I only have to change 1 file to change the menu across the whole site.
Here’s the problem. The menu links have to have the full address like…
<a href="http://domain.com/service/index.html">Service</a>
to make sure they work on every page. Not…
<a href="../service/index.html">Service</a>
I could put http://localhost:80/service/index.html as the full address link and it would work. But, when it comes to uploading the site to domain.com the links would be broken and I’d have to change them everytime I upload a newer version of the site.
Is there anything like this…
<a href="@/service/index.html">Service</a>
… where a sign, for example @, would be whatever domain the site is on?
While starting with
http://etcis an absolute path, and starting with../is relative to the document in question, starting with/will be relative to the root of your site.So your example would simply be
<a href="/service.html">Service</a>.