Menu
Open source RSS
Last reviewed: June 24, 2024

Links

Choose your link type based on your goal:

Although these other types of links still function, replace them with one of the preceding options:

Use ref URIs. Ref URIs have two components:

Note

If you’re using doc-validator in CI, you must upgrade to v5.0.0 to use ref URIs.

doc-validator no longer checks link destinations. You must manually check link destinations in the local preview or fix broken links identified by the weekly website crawl.

ref URIs look up destinations based upon the page’s URL path and the definitions in the page’s front matter.

A link with a ref URI looks like:

markdown
[LINK TEXT](ref:<KEY>)

For the <KEY> , enter an alphabetic term. It can include hyphens (-).

Hugo looks up <KEY> in the value for the refs field in the page’s front matter. If there is no <KEY> in the refs field, or there is no refs field in the front matter, Hugo logs a build error.

Front matter

A partial front matter containing the refs field looks like:

yaml
refs:
  <KEY>:
    - pattern: <URL PATH PREFIX>
      destination: <FULL URL>
    - pattern: <URL PATH PREFIX>
      destination: <FULL URL>
  • <URL PATH PREFIX> - Enter the part of the page URL that represents the project in which the documentation is published.
  • destination - Enter the full URL of the destination page for that project including trailing slashes.

If the page’s URL matches the pattern <URL PATH PREFIX>, then Hugo uses destination as the link destination. If no pattern matches the current page, Hugo logs a build error.

The <FULL URL> destination has the same behavior as described in Link to grafana.com pages

Example

The following Markdown snippet demonstrates the refs front matter and link that uses a ref URI.

markdown
---
refs:
  grafana-alerting:
    - pattern: /docs/grafana/
      destination: https://grafana.com/docs/grafana/<GRAFANA_VERSION>/alerting/fundamentals/data-source-alerting/
    - pattern: /docs/grafana-cloud/
      destination: https://grafana.com/docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/data-source-alerting/
---

# Set up Alerting

## Before you begin

- Check which data sources are compatible with and supported by [Grafana Alerting](ref:grafana-alerting).

In the Grafana page, the link destination is https://grafana.com/docs/grafana/latest/alerting/fundamentals/data-source-alerting/. Hugo replaces the version substitution syntax <GRAFANA_VERSION> with the version inferred from the current page.

In the page Grafana Cloud page, the link destination is https://grafana.com/docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/alert-rules/.

Use a full URL.

Note

The doc-validator linter doesn’t check links that use full URLs.

If you are linking to versioned documentation, use a full URL with version substitution syntax instead of the version path element. For example, in Grafana, use <GRAFANA_VERSION> instead of latest in the URL https://grafana.com/docs/grafana/latest/.

When Hugo renders links with version substitution, it replaces the <SOMETHING_VERSION> syntax with the version inferred from the current page.

To understand the behavior in more detail, refer to About version substitution You use full URLs with the substitution variable so that links resolve to the correct version of documentation without requiring the writer to update the version for each release. For examples of behavior, refer to Examples.

To override the version inferred by version substitution, set the preferred version in the root _index.md file for your documentation. The following YAML snippet sets GRAFANA_VERSION to be latest for that page and all child pages. You must merge the following YAML example with the front matter in the root _index.md file.

yaml
cascade:
  GRAFANA_VERSION: latest

Examples

Link to Grafana documentation:

Start with https://grafana.com/docs/grafana/<GRAFANA_VERSION>/, and add the rest of the URL. Include trailing slashes.

For example, to link to the Developers page with version substitution, use:

markdown
https://grafana.com/docs/grafana/<GRAFANA_VERSION>/developers/
  • If you’re linking from Grafana documentation, <GRAFANA_VERSION> is substituted with the version inferred from the page’s URL.
  • If you’re linking from other documentation, <GRAFANA_VERSION> is substituted with the value of GRAFANA_VERSION from the source page’s front matter.

Link to Grafana Cloud documentation:

Grafana Cloud documentation isn’t versioned and doesn’t require version substitution syntax. Use the full URL.

For example, to link to the Author and run tests page, use:

markdown
https://grafana.com/docs/grafana-cloud/k6/author-run/

Link to Mimir documentation:

Start with https://grafana.com/docs/grafana/<MIMIR_VERSION>/, and add the rest of the URL path.

For example, to link to the Release notes page with version substitution, use:

markdown
https://grafana.com/docs/mimir/<MIMIR_VERSION>/release-notes/
  • If you’re linking from Mimir documentation, <MIMIR_VERSION> is substituted with the version inferred from the page’s URL.
  • If you’re linking from other documentation, <MIMIR_VERSION> is substituted with the value of MIMIR_VERSION from the source page’s front matter.

Use the full URL. Copy the URL exactly from the address bar. If it includes a trailing slash, include it. If it doesn’t include a trailing slash, don’t add one.

For example:

markdown
https://github.com

Link to a heading on a page in one of two ways.

From within the same page:

markdown
Read more in the [Configuration section](#configuration) of this page.

From a different page:

markdown
Read more in the [Grafana Open Source section of the Introduction page](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/fundamentals/#grafana-open-source).

Include the trailing slash before the hash (#) that precedes the page heading.

To convert a heading to an anchor, make the following changes:

  1. Convert to lower case.
  2. Remove any period characters (.).
  3. Replace any character that’s not a lower cased letter, a number, or an underscore (_) with dashes (-).
  4. Trim any preceding or proceeding dashes (-).
  5. Prefix with a #.

The heading Link to page headings becomes the anchor #link-to-page-headings.