If you've any sense at all, you won't want to build your site with all your pages in one directory - especially as your site grows. Before building any site it's a good idea to think about your directory structure. Thankfully Hitop makes working with multiple directories a doddle.
Let's look at our radio example again. We've got a few pages in there but in a few months, we think the site may be huge. Time to start planning.
We have one obvious section - pirate radio. Lets create a directory called pirate/ then to put that in. Radio One and 5 Live are both national stations so let's put those pages in a national/ directory. GLR and xfm are local stations, so local/ seems a reasonable idea. This leaves us with the following nav file:
Contents=contents.html
Pirate Radio=
Radio London=pirate/radiolondon.html
Radio Caroline=pirate/radiocaroline.html
Radio Luxemburg=pirate/radioluxemburg.html
BBC Radio One=national/radio1.html
BBC Radio 5 Live=national/radio5live.html
BBC GLR=national/bbcglr.html
xfm=national/xfm.html
Note that all our links are local links.
That's all well and good but once we've moved things round, and added the
fact that some files are in subdirectories to our Makefile, our source files
in the sub-directories can't find the template anymore! What we need is
${RELPATH}!
${RELPATH} is a rather funky thing. Basically it puts in the path back to the root directory of your site - this being the place you run hitop from, or where your hitop.base is if you're using Hitoplive.
In order to convert our templates, we need to change
<@FILE SRC="template.hitop">
to
<@FILE
SRC="${RELPATH}template.hitop">
For a file like xfm.html which is in our new local/ directory, ${RELPATH} finds its way to the root directory of your site, and invisibly changes the statement to:
<@FILE SRC="../template.hitop">
No matter what directory you are in, ${RELPATH} will stick in enough ../'s to get back to the base directory. This is obviously very useful as you don't have to remember where your file lives, and indeed you can move it to a different place without having to ammend all the link tags.
You can use ${RELPATH} any time you specify an url, like in an <A
HREF=".."> or in an IMG tag.
Although you could use ${RELPATH} in every url, there isn't much point if you don't need to. For example, if we wanted an image in xfm.html:
<img src="${RELPATH}local/images/xfm.gif" alt="XFM
Logo">
Hitop would turn this into:
<img src="../local/images/xfm.gif" alt="XFM
Logo">
Which is identical to:
<img src="images/xfm.gif" alt="XFM
Logo">
which you could have put in in the first place! Of course it doesn't do any harm at all - it just adds a few bytes to your page.
Hitop can work with it's templates in a seperate directory too. I keep all my templates in one directory called build/ directory, so each source file has the following to locate it:
<@FILE
SRC="${relpath}build/template_name.hitop">
External nav files however must always sit in the base directory of your site - this is where @NAV always looks for it. ${RELPATH} will also not work with the @NAV command. As such
<@NAV SRC="${RELPATH}menu.nav">
will produce an error message. External nav files should always be called by
<@NAV SRC="menu.nav">
even when the template is in a sub-directory on a site. This is a rather perculiar quirk of Hitop's.