hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

ref.md (1672B)

    1 ---
    2 title: ref
    3 linktitle: ref
    4 description: Returns the absolute permalink to a page.
    5 date: 2017-02-01
    6 publishdate: 2017-02-01
    7 lastmod: 2020-09-05
    8 categories: [functions]
    9 menu:
   10   docs:
   11     parent: "functions"
   12 keywords: [cross references, anchors]
   13 signature: ["ref . PAGE"]
   14 workson: []
   15 hugoversion:
   16 relatedfuncs: [relref]
   17 deprecated: false
   18 aliases: []
   19 ---
   20 
   21 This function takes two parameters:
   22 
   23 - The context of the page from which to resolve relative paths, typically the current page (`.`)
   24 - The path to a page, with or without a file extension, with or without an anchor. A path without a leading `/` is first resolved relative to the given context, then to the remainder of the site.
   25 
   26 ```go-html-template
   27 {{ ref . "about" }}
   28 {{ ref . "about#anchor" }}
   29 {{ ref . "about.md" }}
   30 {{ ref . "about.md#anchor" }}
   31 {{ ref . "#anchor" }}
   32 {{ ref . "/blog/my-post" }}
   33 {{ ref . "/blog/my-post.md" }}
   34 ```
   35 
   36 To return the absolute permalink to another language version of a page:
   37 
   38 ```go-html-template
   39 {{ ref . (dict "path" "about.md" "lang" "fr") }}
   40 ```
   41 
   42 To return the absolute permalink to another Output Format of a page:
   43 
   44 ```go-html-template
   45 {{ ref . (dict "path" "about.md" "outputFormat" "rss") }}
   46 ```
   47 
   48 Hugo emits an error or warning if the page cannot be uniquely resolved. The error behavior is configurable; see [Ref and RelRef Configuration](/content-management/cross-references/#ref-and-relref-configuration). 
   49 
   50 This function is used by Hugo's built-in [`ref`](/content-management/shortcodes/#ref-and-relref) shortcode. For a detailed explanation of how to leverage this shortcode for content management, see [Links and Cross References](/content-management/cross-references/).