Monday, 26 August 2013

Using a relative URL scheme effectively

Using a relative URL scheme effectively

Using has all of the issues on anchor-tags that were described in this
question on base tags making it hard to use on my site.
I have a navigation menu in my site which references different parts of my
site
for example
main/
|_index.html
|_section1/
|_1a.html
|_1b.html
and the navigation section on each page looks like
<div id="nav">
<ul>
<li><a href="index.html">home</a></li>
<li><a href="section1/1a.html">1a</a></li>
<li><a href="section1/1b.html">1b</a></li>
</ul>
</div>
This works fine for all the pages on in the main folder but for pretty
obvious reasons fails when I'm viewing a page in the section1 folder. I
can't use <base> because I have a large number of anchors in documents
(and I'm using markdown so I cant change the reference format easily).
I'm concerned that if I use absolute references on all my pages, when I
upload this site to a server it will be a huge amount of work to replace
the absolute reference on each page with a different one.
In addition main is a few levels down in my /home/ directory and I would
prefer not to have to type a long path-name each time I refer to something
if possible
I guess if I was pushed I could use sed to change all instances of the
absolute path with something else but I wondered if there was an easier,
obvious way of dealing with this in html that I'm missing. thanks

No comments:

Post a Comment