RelRef

選項映射包含:

path
(string) 頁面的路徑,相對於內容目錄。必填。
lang
(string) 要搜尋的語言(網站)。預設為當前語言。選填。
outputFormat
(string) 要搜尋的輸出格式。預設為當前輸出格式。選填。

以下範例顯示當使用英文語言版本的網站訪問頁面時,所呈現的輸出結果:

{{ $opts := dict "path" "/books/book-1" }}
{{ .RelRef $opts }} → /en/books/book-1/

{{ $opts := dict "path" "/books/book-1" "lang" "de" }}
{{ .RelRef $opts }} → /de/books/book-1/

{{ $opts := dict "path" "/books/book-1" "lang" "de" "outputFormat" "json" }}
{{ .RelRef $opts }} → /de/books/book-1/index.json

預設情況下,若 Hugo 無法解析路徑,會拋出錯誤並終止建構。你可以在網站配置中將此設定為警告,並指定當路徑無法解析時返回的 URL。

hugo.
     
refLinksErrorLevel: warning
refLinksNotFoundURL: /some/other/url
refLinksErrorLevel = 'warning'
refLinksNotFoundURL = '/some/other/url'
{
   "refLinksErrorLevel": "warning",
   "refLinksNotFoundURL": "/some/other/url"
}