Absolute and Relative Paths
What's covered?
An explanation of the difference.
What's the difference?
- A link that has an absolute path will tell the computer which server to go to and then all the folders that you have to drill down through to get to the target.
- A link that has a relative path will be written to tell the computer how to get from the folder with the currently viewed topic to the target.
Which you use will depend on whether the path between the topic with the link and the target topic will be constant and whether they are on the same server.
Relative Paths
It might be easier to start by explaining relative paths. If target topic is on the same server as the link and that will be true for all users, then a relative path will probably be what you use.
First let's take a simple structure.
- By prefixing the first slash (/) in the path with a single (.) dot, you are declaring that the path starts in the same folder.
- By prefixing the first slash (/) in the path with a double (..) dot, you are declaring that the path starts in the folder above. To go one folder higher again, you would add a further ../
Examples
Folder for topic with link |
Folder for target topic |
Relative Path |
Folder_A |
Folder_A |
./target_topic.htm The target is in the same folder so indicate that with a single dot and name the file. |
Folder_A |
Folder_B |
./Folder_B/target_topic.htm The start point of the path is still the same folder but this time the target is in a sub folder. |
Folder_A |
Folder_C |
./Folder_B/Folder_C/target_topic.htm The start point of the path is still the same folder but this time the target is in a sub folder of a sub folder so both get specified. |
Folder_C |
Folder_A |
../../target_topic.htm This time the path shows two levels up and the target will be found there. |
Folder_C |
Folder_D |
../../Folder_D/target_topic.htm The two sets of dots take us back to A from where you can specify any other folder at the same level as A. |
Folder_C |
Folder_E |
../../Folder_D/Folder_E/target_topic.htm Just add any further levels from the previous example. |
Generally, relative paths are shorter. When creating links in RoboHelp, they will automatically be written this way.
Absolute Paths
If the target topic is not on the same server or it will not be constant, then you have to use absolute links. Here you are not backtracking to "the fork in the road" but specifying a start point.
- If it is a website for example the link would be written as say https://www.grainge.org/Folder_A/Folder_B/target_topic.htm.
- If the target topic is on another server in your network, rather than setting out all the backtracking information, you start by using the server name. The format would be something like \\server_name\Folder_A\Folder_B\Folder_C\target_topic.htm.
Note the use of backslashes for another server on your network.
RoboHelp Tip
If you need to manually add a relative path from a topic to the root of your project, take a look at the Head section of the HTML code. Look for the CSS path, assuming your CSS is in the root.
- If it is ../stylesheet.css and perhaps you want to add a reference to a javascript file also in the root, then the path would be ../myjavascriptfile.js
- If it is ../../stylesheet.css and perhaps you want to add a reference to a javascript file also in the root, then the path would be ../../myjavascriptfile.js
Donations
If you find the information and tutorials on my site save you time figuring it out for yourself and help improve what you produce, please consider making a small donation.