diff --git a/content/en/content-management/cross-references.md b/content/en/content-management/cross-references.md index 5ec7dc545..151b91514 100644 --- a/content/en/content-management/cross-references.md +++ b/content/en/content-management/cross-references.md @@ -17,15 +17,35 @@ toc: true The `ref` and `relref` shortcodes display the absolute and relative permalinks to a document, respectively. -## Use `ref` and `relref` +## Use of `ref` and `relref` -```go-html-template -{{}} -{{}} -{{}} -{{}} -{{}} -{{}} +The `ref` and `relref` shortcodes require a single parameter: the path to a content document, with or without a file extension, with or without an anchor. Paths without a leading `/` are first resolved relative to the current page, then to the remainder of the site. + +``` +. +└── content + ├── about + | ├── _index.md + | └── credits.md + ├── pages + | ├── document1.md + | └── document2.md // has anchor #anchor + ├── products + | └── index.md + └── blog + └── my-post.md +``` + +The pages can be referenced as follows: + + +```text +{{}} // <- From pages/document1.md, relative path +{{}} +{{}} +{{}} +{{}} // <- From pages/document2.md +{{}} // <- From anywhere, absolute path {{}} {{}} {{}} @@ -33,15 +53,22 @@ The `ref` and `relref` shortcodes display the absolute and relative permalinks t {{}} ``` -To generate a hyperlink using `ref` or `relref` in markdown: +index.md can be reference either by its path or by its containing folder without the ending `/`. \_index.md can be referenced only by its containing folder: -```md -[About]({{}} "About Us") +```text +{{}} // <- References /about/_index.md +{{}} // Raises REF_NOT_FOUND error +{{}} // <- References /about/credits.md + +{{}} // <- References /products/index.md +{{}} // <- References /products/index.md ``` -The `ref` and `relref` shortcodes require a single parameter: the path to a content document, with or without a file extension, with or without an anchor. +To generate a hyperlink using `ref` or `relref` in markdown: -**Paths without a leading `/` are first resolved relative to the current page, then to the remainder of the site. +```text +[About]({{}} "About Us") +``` Hugo emits an error or warning if a document cannot be uniquely resolved. The error behavior is configurable; see below.