Design
Hyperlinks
A Step-by-Step Guide to Embedding Hyperlinks in Your Documents
ENTERPRISE FEATURE
Available for:
Carbone Cloud
Carbone On-premise
Embedded Carbone JS
v3.0+
With Carbone, you can seamlessly integrate hyperlinks into various elements of your DOCX, XLSX, PPTX, ODT, ODS, ODP, and ODG templates.
How to include Hyperlinks?
Hyperlinks can be dynamically applied to various elements such as text, images, tables, and lists within your documents. Follow these steps to insert hyperlinks:
- Select the Element: Right-click on the text, image, table, or list item you want to hyperlink.
- Insert Hyperlink: Choose the "Hyperlink" option from the context menu.
- Enter the Carbone Tag: Input the appropriate Carbone tag and confirm your selection.
Important Notes:
- Automatic Character Replacement: If your text editor automatically replaces curly braces with special characters like %256B, this will not affect the functionality.
- Static and Dynamic URL Mixing: It is not feasible to combine a static URL with a dynamic URL tag (e.g.,
https://carbone.io{d.url}
). In such cases, Carbone will retain only the dynamic part{d.url}
. - XLSX Compatibility: For XLSX files, ensure the tag is not enclosed in curly braces. For instance, use
d.url
instead of{d.url}
. Ifhttp://
appears befored.url
, it will work.
Hyperlink validation
Before dynamically injecting hyperlinks into your reports, Carbone performs a validation check to ensure the URL format is correct. A valid URL must include:
- Protocol (Optional): Either
http://
orhttps://
. If omitted, Carbone will automatically prependhttps://
. - Root Domain (Required): A root domain with a length between 2 and 256 characters.
- Top-Level Domain (TLD) (Required): Such as
.com
,.org
,.fr
, etc.
If the URL fails to meet these criteria, it will be replaced with the default URL: https://carbone.io/documentation.html#hyperlink-validation
:defaultURL(url)
If a dynamic hyperlink or an HTML anchor tag fails the URL verification, you can use the :defaultURL
formatter to specify a fallback URL. This ensures that invalid URLs are replaced with a valid alternative.
If a dynamic hyperlink or an HTML anchor tag is injected into a report and the URL verification fails, the :defaultURL
formatter can be used to replace the default error URL.
If the provided URL isn’t valid, it will be replaced with https://carbone.io/documentation.html#hyperlink-validation
.
When inserting dynamic hyperlinks, chain the :defaultURL
formatter to the tag, like this:
{d.url:defaultURL('https://carbone.io')}
It is possible to pass another tag as an dynamic argument:
{d.url:defaultURL(.urlOnError)}
When using the :html
formatter, the :defaultURL
should be placed before:
{d.content:defaultURL(.urlOnError):html}