Docs

Link

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

Overview  

  Important

The --minify flag of hugo purges HTML whitespace by default. Unfortunately, this also removes the spacing behind the visual cue of external links. Add the following configuration to your main configuration to prevent this:

[minify]
 [minify.tdewolff.html]
   keepWhitespace = true

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 or published asset.

Use positional arguments to provide a link to a site page. Hinode uses the inner text for the link name when available, else it uses the referenced page title. You can provide either relative or absolute paths.

markdown
- {{< link "kbd" />}}
- {{< link "kbd" >}}Internal link with relative path{{< /link >}}

Provide a # character to include an anchor link within a page. The browser will then jump the specified section when clicking on the link. Please note that Hinode does not validate the anchor part itself.

markdown
- {{< link "#arguments" >}}Local arguments{{< /link >}}
- {{< link "image#arguments" >}}Image arguments{{< /link >}}

Provide a link that starts with http to reference an external page. When you omit the link text, Hinode will display the hostname instead.

markdown
- {{< link "https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements" />}}
- {{< link "https://developer.mozilla.org" >}}External link{{< /link >}}

You can configure so-called named links in your site parameters. The following example defines hugo_docs.

[links]
    hugo_docs = "https://gohugo.io/documentation/"

Reference the named link using a positional argument.

markdown
{{< link hugo_docs />}}

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 href=hugo_docs cue=false tab=false >}}Named link opening in current tab w/o icon{{< /link >}}
- {{< link href=hugo_docs cue=true tab=true >}}Named link opening in new tab with icon{{< /link >}}
- {{< link href=".." case=false >}}Internal link with lower case{{< /link >}}

Arguments  

  Important

The link shortcode recognizes language-specific pages, identified by a language prefix. For example, use /fr/about to link to the French translation of the about page. Do not use the alias /fr/a-propos in this case.

The shortcode supports a single unnamed parameter, or various named parameters. The unnamed parameter is recognized as a url if it starts with http, else it is treated as either a named link or relative internal reference (in that order). Any inner text is rendered as the link title, otherwise it uses the host name (for external links), link title (for internal links), or anchor name (for any local references containing a #). The shortcode supports the following named arguments:

Name Type Required Default Comment
case bool true Flag to indicate if the retrieved title (e.g. no inner text is provided) of an internal link should use its original case. If false, the title is set to lower case.
class string Class attributes of the element. It supports Bootstrap attributes to modify the styling of the element.
cue bool Flag to indicate if an external link should show a visual cue, defaults to the setting main.externalLinks.cue in the site’s parameters.
exact bool v1.20.0      Renders the provided title as-is, without adjusting the case. Overrides the site’s title case setting.
external bool Flag to indicate if a link that contains a baseURL host should be forced as external.
force bool v0.27.20      Flag to indicate a link should bypass any language redirection. Only applicable when the site param enableLanguageSelectionStorage is set to true. When force is true, the link to a local page is kept as is.
href string, template.URL, url Address for the button or hyperlink. When set for a card group, a button is added if the list exceeds the maximum number of cards to display.
name string v1.0.0      Use href instead. Alias of href.
tab bool Flag to indicate if an external link should open in a new tab, defaults to setting main.externalLinks.tab in the site’s parameters.
title string, hstring.RenderedString, hstring.HTML, template.HTML v0.26.0      Title of the element. If the element references a (local) page, the title overrides the referenced page’s title.
url string v1.0.0      Use href instead. Alias of href.
Name Type Required Default
case bool true
Flag to indicate if the retrieved title (e.g. no inner text is provided) of an internal link should use its original case. If false, the title is set to lower case.
class string
Class attributes of the element. It supports Bootstrap attributes to modify the styling of the element.
cue bool
Flag to indicate if an external link should show a visual cue, defaults to the setting main.externalLinks.cue in the site’s parameters.
exact bool
v1.20.0      Renders the provided title as-is, without adjusting the case. Overrides the site’s title case setting.
external bool
Flag to indicate if a link that contains a baseURL host should be forced as external.
force bool
v0.27.20      Flag to indicate a link should bypass any language redirection. Only applicable when the site param enableLanguageSelectionStorage is set to true. When force is true, the link to a local page is kept as is.
href string, template.URL, url
Address for the button or hyperlink. When set for a card group, a button is added if the list exceeds the maximum number of cards to display.
name string
v1.0.0      Use href instead. Alias of href.
tab bool
Flag to indicate if an external link should open in a new tab, defaults to setting main.externalLinks.tab in the site’s parameters.
title string, hstring.RenderedString, hstring.HTML, template.HTML
v0.26.0      Title of the element. If the element references a (local) page, the title overrides the referenced page’s title.
url string
v1.0.0      Use href instead. Alias of href.