Link

Share via

Use the link shortcode to add a managed link to your page content.

Overview

Since Hinode v0.16.8 you can add a managed link to your page content using a configurable shortcode. Managed links refer to an external URL that is centrally maintained in the site’s parameters. The shortcode also supports internal links that refer to a regular page.

markdown
{{< link mozilla_image />}}

Arguments

The shortcode supports a single unnamed parameter, or various named parameters. The unnamed parameter is recognized as a named link if it does not contain any “/”, otherwise it is treated as a url. Any inner text is rendered as the link title, otherwise it uses the host name (for external links) or page name (for internal links). The shortcode supports the following named arguments:

ArgumentRequiredDescription
nameNoOptional name of the link maintained in the “links” section of the site’s parameters. If omitted, the “url” argument should be provided instead.
urlNoOptional url of the link, including the scheme (“http” or “https”). If omitted, the “name” argument should be provided instead.
cueNoOptional flag to indicate if an external link should show a visual cue, defaults to setting “main.externalLinks.cue” in the site’s parameters.
tabNoOptional flag to indicate if an external link should open in a new tab, defaults to setting “main.externalLinks.tab” in the site’s parameters.
caseNoOptional flag to indicate if the retrieved title (e.g. no inner text is provided) of an internal link should use its original case, defaults to true. If false, the title is set to lower case.
classNoOptional class attribute of the anchor element.

Site configuration

You can configure the behavior of managed links in the /config/_default/params.toml file in the main.externalLinks section. Manage the named links in the links section of the same file:

[links]
    mozilla_image = "https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images"

Examples

Use either named links or common url’s to generate a managed link. Any unnamed link is recognized as internal reference to page when it contains at least one / character. Use the cue and tab arguments to override the default behavior of displaying and opening external links. Omit the link’s content to generate a reference to the host (for external links) or the target page’s title (for internal links). Lastly, set case to false to set the obtained page title to lower case.

markdown
- {{< link mozilla_image >}}Named link with default settings{{< /link >}}
- {{< link name=mozilla_image cue=false tab=false >}}Named link opening in current tab w/o icon{{< /link >}}
- {{< link name=mozilla_image cue=true tab=true >}}Named link opening in new tab with icon{{< /link >}}
- {{< link mozilla_image />}}
- {{< link "https://developer.mozilla.org" >}}External link{{< /link >}}
- {{< link "/getting-started" >}}Internal link with title{{< /link >}}
- {{< link "/license" />}}
- {{< link url="/license" case=false />}}
Last updated: August 5, 2023 • Add class argument (3547368)