The Link module provides one or several fields for storing links. It supports additional link text titles and display settings.
Drupal 8: The Link module is a core module that only allows external links. Internal links can be added with the core module Entity Reference.
Drupal 7: The Link module allows external and internal links. It does not allow adding links to a menu or navigation.
Installation: The Link module is part of Drupal core and can be enabled from the Extend page (admin/build/modules).
Input format: The Link module only allows external (i.e. absolute) links. Links can include anchors or query strings.
Validation: Links must include the web protocol (http:// or https://) in order to validate. Validation takes place after filling in the field. Other scheme names (e.g. ftp, git, etc.) are not supported.
Link texts: Link texts (called "Link titles" in D7) can be added to each URL. Whether this is allowed or required can be set in the field management. Placeholder text can be added to appear in the fields before the user adds their own content.
Display settings allow displaying either the link text or the URL, and specifying the number of characters at which the link text should be trimmed.
rel="nofollow" option notifies search engines that the link should not be followed. (See Wikipedia for details.)
Drupal 7 and earlier
The Link module provides one or several fields for storing absolute and relative links (often described as external and internal links or URLs). It supports additional link text titles, site-wide tokens for titles and title attributes, target attributes, CSS class attribution, static repeating values, and input conversion.
Link titles for URLs can be made mandatory, set to appear instead of URLs, set to be optional (default), or left out entirely. If no link text title is provided, the trimmed version of the complete URL is displayed.
The target attribute should be set to "_blank", "top", or left out completely (checkboxes provide info).
The "rel=nofollow" attribute advises search engines to not follow the link. More info is available on Wikipedia.
Input formats for D7
The Link module supports absolute and relative links, often described as "external" and "internal" links, respectively. Links are validated during the saving of the node.
- Absolute links Complete URLs (e.g.
http://example.com) are displayed as such (e.g. http://example.com). The web protocol (e.g. http:// or https://) must be included, otherwise the link will not validate.
- Relative links are input without the domain name and without a preceding slash (e.g.
admin/build). These are then converted to a URL link (e.g. http://example.com/admin/build) or - where applicable - to the URL alias (e.g. http://example.com/project/link for
- Link to the front page:
<front>results in a link to the front page of the site, as it is set under 'Site information' or by a contributed module.
- Anchors and query strings may also be used
Output and Theming
The default output of a field 'My new link' with a url [URL], link text or title [Title] and a [target_value] is
<div class="field_my_new_link" target="[target_value]"><a href="[URL]">[Title]</a></div>.
Theming: The Link module is mainly a data storage field in a modular framework, therefore the theming and output depends on the site builder and the settings in other modules.
Many Drupal modules control the output of fields and handle rules, user actions, markup dependencies, and can vary the output in different scenarios.
Useful modules for this purpose include Views, Display Suite, Panels, and others.
Useful blog posts that show creative uses of the Link module, or modules useful in conjunction with the Link module:
- Creating an embedded video or audio player for a link field
- Filter allowed protocols module This module allows users to change protocols set by Drupal to include new protocols such as Skype. For reference, the default protocols are: 'ftp', 'http', 'https', 'irc', 'mailto', 'news', 'nntp', 'rtsp', 'sftp', 'ssh', 'tel', 'telnet', and 'webcal'.
- Advanced Link module - Adds a new widget for autocomplete functionality, and allows filtering the type of links allowed.
- Link Favicon Formatter module - Allows changing a link's formatting to display the favicon of the URL alongside the link.