Relative and Absolute Links
From LibreOffice Help
When you include hyperlinks, two factors must be taken into account: whether they are set as relative or absolute on saving, and whether or not the file is present.
- Choose Tools - Options - Load/Save - General and specify in the Save URLs relative to field if LibreOffice creates relative or absolute hyperlinks. Relative linking is only possible when the document you are working on and the link destination are on the same drive.
- You should create the same directory structure on your hard disk as that which exists in the web space hosted by your Internet provider. Call the root directory for the homepage on your hard disk "homepage", for example. The start file is then "index.html", the full path being "C:\homepage\index.html" (assuming Windows operating system). The URL on your Internet provider's server might then be as follows: "http://www.myprovider.com/mypage/index.html". With relative addressing, you indicate the link relative to the location of the output document. For example, if you placed all the graphics for your homepage in a subfolder called "C:\homepage\images", you would need to give the following path to access the graphic "picture.gif": "images\picture.gif". This is the relative path, starting from the location of the file "index.html". On the provider's server, you would place the picture in the folder "mypage/images". When you transfer the document "index.html" to the provider's server through the File - Save As' dialog, and if you have marked the option Copy local images to Internet under Tools - Options' - Load/Save - HTML Compatibility, LibreOffice will automatically copy the graphic to the correct directory on the server.
- An absolute path such as "C:\homepage\graphics\picture.gif" would no longer function on the provider server. Neither a server nor the computer of a reader needs to have a C hard drive: operating systems such as Unix or MacOS do not recognize drive letters, and even if the folder homepage\graphics existed, your picture would not be available. It is better to use relative addressing for file links.
- A link to a web page, for example, "www.example.com" or "www.myprovider.com/mypage/index.html" is an absolute link.
- LibreOffice also reacts differently, depending on whether the file referred to in the link exists, and where it is located. LibreOffice checks every new link and sets a target and protocol automatically. The result can be seen in the generated HTML code after saving the source document.
- The following rules apply: A relative reference ("graphic/picture.gif") is only possible when both files exist on the same drive. If the files are on different drives in your local file system, the absolute reference follows the "file:" protocol ("file:///data1/xyz/picture.gif"). If the files are on different servers or if the target of the link is not available, the absolute reference uses the "http:" protocol ("http://data2/abc/picture.gif").
- Be sure to organize all files for your homepage on the same drive as the start file of the homepage. In this way, LibreOffice can set the protocol and target so that the reference on the server is always correct.
Chủ đề Liên quan