| 1 |
--- |
| 2 |
title: Ref |
| 3 |
description: Returns the absolute URL of the page with the given path, language, and output format. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: string |
| 9 |
signatures: [PAGE.Ref OPTIONS] |
| 10 |
--- |
| 11 |
|
| 12 |
## Usage |
| 13 |
|
| 14 |
The `Ref` method requires a single argument: an options map. |
| 15 |
|
| 16 |
## Options |
| 17 |
|
| 18 |
{{% include "_common/ref-and-relref-options.md" %}} |
| 19 |
|
| 20 |
## Examples |
| 21 |
|
| 22 |
The following examples show the rendered output for a page on the English version of the site: |
| 23 |
|
| 24 |
```go-html-template |
| 25 |
{{ $opts := dict "path" "/books/book-1" }} |
| 26 |
{{ .Ref $opts }} → https://example.org/en/books/book-1/ |
| 27 |
|
| 28 |
{{ $opts := dict "path" "/books/book-1" "lang" "de" }} |
| 29 |
{{ .Ref $opts }} → https://example.org/de/books/book-1/ |
| 30 |
|
| 31 |
{{ $opts := dict "path" "/books/book-1" "lang" "de" "outputFormat" "json" }} |
| 32 |
{{ .Ref $opts }} → https://example.org/de/books/book-1/index.json |
| 33 |
``` |
| 34 |
|
| 35 |
## Error handling |
| 36 |
|
| 37 |
{{% include "_common/ref-and-relref-error-handling.md" %}} |