Relativní a absolutní odkazy
Při vkládání hypertextových odkazů je třeba myslet na dvě věci: zda je odkaz relativní nebo absolutní a zda je nebo není soubor přítomen.
-
Zvolte LibreOffice - PředvolbyNástroje - Možnosti - Načítání/ukládání - Obecné a určete v poli Ukládat URL relativně k, zda se mají v LibreOffice vytvářet relativní nebo absolutní odkazy. Relativní odkazy je možné použít jen tehdy, jsou-li dokument, na kterém pracujete, a cíl odkazu na stejném disku.
-
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 LibreOffice - PreferencesTools - 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.
-
Odkaz na webovou stránku, například "www.example.com" nebo "www.myprovider.com/mypage/index.html", je absolutní odkaz.
-
LibreOffice také různě reaguje, pokud odkazovaný soubor existuje nebo ne a v kde je umístěn. LibreOffice kontroluje každý nový odkaz a automaticky nastavuje cíl a protokol. Výsledek si můžete zobrazit ve vygenerovaném HTML kódu po uložení dokumentu.
-
Platí následující pravidla: Relativní odkaz (obrazky/obrazek.gif) je možný, pouze pokud oba soubory existují na stejném disku. Jsou-li soubory na různých jednotkách lokálního systému, bude absolutní odkaz v protokolu file: (file:///data1/xyz/obrazek.gif). Jsou-li soubory na různých serverech nebo není-li cíl odkazu dostupný, použije se absolutní odkaz protokol http: (http://data2/abc/obrazek.gif).
-
Ujistěte se, že všechny soubory pro vaši stránku máte na stejném disku jako počáteční soubor. Tak může LibreOffice nastavit protokol a cíl, aby odkazy na serveru byly vždy správné.
Když umístíte kurzor myši na hypertextový odkaz, zobrazí se tip s absolutním odkazem, jelikož LibreOffice interně používá absolutní cesty. Kompletní cestu a adresu si můžete prohlédnout jen ve výsledku HTML exportu, když načtete HTML soubor jako "Text" nebo jej otevřete v textovém editoru.