mirror of
				https://github.com/gohugoio/hugo.git
				synced 2024-05-11 05:54:58 +00:00 
			
		
		
		
	Squashed 'docs/' changes from 7297c1172..d3eb97a33
d3eb97a33 Document .IsSection page variable a068bcf5c Ace and Amber support was removed with #6609 5cd9ca4b2 Mention MacPorts also on the Installing page (#1215) 0ae8f5c19 Add instructions for using Macports d50aba8f0 Revise ref and relref function pages a17e25d6f Update quick-start.md: move notice about drafts up cf87a5da2 Update macOS tarball installation instructions (#1203) 2e701f8f3 Corrected the url for index function link 736bd59e0 Clarify treatment of zero weights (#1207) 42a19f479 Fix example of output from urlize function 34f8de26d Revise content-management/cross-references 252435a95 Rewrite Translation of Strings f0882bc14 Remove note that has been outdated by v0.71.0 dfe28ceb5 Improve mounts module config 58029627d Fix erroneous example code piping to if git-subtree-dir: docs git-subtree-split: d3eb97a3328f5390801bbce017233ce895fc2d28
This commit is contained in:
		| @@ -1,17 +1,17 @@ | ||||
| --- | ||||
| title: ref | ||||
| linktitle: ref | ||||
| description: Looks up a content page by logical name. | ||||
| description: Returns the absolute permalink to a page. | ||||
| godocref: | ||||
| date: 2017-02-01 | ||||
| publishdate: 2017-02-01 | ||||
| lastmod: 2019-12-28 | ||||
| lastmod: 2020-09-05 | ||||
| categories: [functions] | ||||
| menu: | ||||
|   docs: | ||||
|     parent: "functions" | ||||
| keywords: [cross references, anchors] | ||||
| signature: ["ref . CONTENT"] | ||||
| signature: ["ref . PAGE"] | ||||
| workson: [] | ||||
| hugoversion: | ||||
| relatedfuncs: [relref] | ||||
| @@ -19,22 +19,33 @@ deprecated: false | ||||
| aliases: [] | ||||
| --- | ||||
|  | ||||
| `ref` and `relref` look up a content page by logical name (`ref`) or relative path (`relref`) to return the permalink: | ||||
| This function takes two parameters: | ||||
|  | ||||
| ``` | ||||
| - The context of the page from which to resolve relative paths, typically the current page (`.`) | ||||
| - 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. | ||||
|  | ||||
| ```go-html-template | ||||
| {{ ref . "about" }} | ||||
| {{ ref . "about#anchor" }} | ||||
| {{ ref . "about.md" }} | ||||
| {{ ref . "about.md#anchor" }} | ||||
| {{ ref . "#anchor" }} | ||||
| {{ ref . "/blog/my-post" }} | ||||
| {{ ref . "/blog/my-post.md" }} | ||||
| ``` | ||||
|  | ||||
| {{% note "Usage Note" %}} | ||||
| `ref` looks up Hugo "Regular Pages" only. It can't be used for the homepage, section pages, etc. | ||||
| {{% /note %}} | ||||
| To return the absolute permalink to another language version of a page: | ||||
|  | ||||
| It is also possible to pass additional arguments to link to another language or an alternative output format. Therefore, pass a map of arguments instead of just the path. | ||||
|  | ||||
| ```  | ||||
| {{ ref . (dict "path" "about.md" "lang" "ja" "outputFormat" "rss") }}  | ||||
| ```go-html-template | ||||
| {{ ref . (dict "path" "about.md" "lang" "fr") }} | ||||
| ``` | ||||
|  | ||||
| These functions are used in two of Hugo's built-in shortcodes. You can see basic usage examples of both `ref` and `relref` in the [shortcode documentation](/content-management/shortcodes/#ref-and-relref). | ||||
| To return the absolute permalink to another Output Format of a page: | ||||
|  | ||||
| For an extensive explanation of how to leverage `ref` and `relref` for content management, see [Cross References](/content-management/cross-references/). | ||||
| ```go-html-template | ||||
| {{ ref . (dict "path" "about.md" "outputFormat" "rss") }} | ||||
| ``` | ||||
|  | ||||
| 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).  | ||||
|  | ||||
| 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/). | ||||
|   | ||||
| @@ -1,17 +1,17 @@ | ||||
| --- | ||||
| title: relref | ||||
| # linktitle: relref | ||||
| description: Looks up a content page by relative path. | ||||
| linktitle: relref | ||||
| description: Returns the relative permalink to a page. | ||||
| godocref: | ||||
| date: 2017-02-01 | ||||
| publishdate: 2017-02-01 | ||||
| lastmod: 2019-12-28 | ||||
| lastmod: 2020-09-05 | ||||
| categories: [functions] | ||||
| menu: | ||||
|   docs: | ||||
|     parent: "functions" | ||||
| keywords: [cross references, anchors] | ||||
| signature: ["relref . CONTENT"] | ||||
| signature: ["relref . PAGE"] | ||||
| workson: [] | ||||
| hugoversion: | ||||
| relatedfuncs: [ref] | ||||
| @@ -19,22 +19,40 @@ deprecated: false | ||||
| aliases: [] | ||||
| --- | ||||
|  | ||||
| `ref` and `relref` look up a content page by logical name (`ref`) or relative path (`relref`) to return the permalink: | ||||
| This function takes two parameters: | ||||
|  | ||||
| ``` | ||||
| - The context of the page from which to resolve relative paths, typically the current page (`.`) | ||||
| - 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. | ||||
|  | ||||
| ```go-html-template | ||||
| {{ relref . "about" }} | ||||
| {{ relref . "about#anchor" }} | ||||
| {{ relref . "about.md" }} | ||||
| {{ relref . "about.md#anchor" }} | ||||
| {{ relref . "#anchor" }} | ||||
| {{ relref . "/blog/my-post" }} | ||||
| {{ relref . "/blog/my-post.md" }} | ||||
| ``` | ||||
|  | ||||
| {{% note "Usage Note" %}} | ||||
| `relref` looks up Hugo "Regular Pages" only. It can't be used for the homepage, section pages, etc. | ||||
| {{% /note %}} | ||||
| The permalink returned is relative to the protocol+host portion of the baseURL specified in the site configuration. For example: | ||||
|  | ||||
| It is also possible to pass additional arguments to link to another language or an alternative output format. Therefore, pass a map of arguments instead of just the path.  | ||||
| Code|baseURL|Permalink | ||||
| :--|:--|:-- | ||||
| `{{ relref . "/about" }}`|`http://example.org/`|`/about/` | ||||
| `{{ relref . "/about" }}`|`http://example.org/x/`|`/x/about/` | ||||
|  | ||||
| ```  | ||||
| {{ relref . (dict "path" "about.md" "lang" "ja" "outputFormat" "rss") }} | ||||
| To return the relative permalink to another language version of a page: | ||||
|  | ||||
| ```go-html-template | ||||
| {{ relref . (dict "path" "about.md" "lang" "fr") }} | ||||
| ``` | ||||
|  | ||||
| These functions are used in two of Hugo's built-in shortcodes. You can see basic usage examples of both `ref` and `relref` in the [shortcode documentation](/content-management/shortcodes/#ref-and-relref). | ||||
| To return the relative permalink to another Output Format of a page: | ||||
|  | ||||
| For an extensive explanation of how to leverage `ref` and `relref` for content management, see [Cross References](/content-management/cross-references/). | ||||
| ```go-html-template | ||||
| {{ relref . (dict "path" "about.md" "outputFormat" "rss") }} | ||||
| ``` | ||||
|  | ||||
| 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).  | ||||
|  | ||||
| This function is used by Hugo's built-in [`relref`](/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/). | ||||
|   | ||||
| @@ -53,8 +53,8 @@ The preceding partial would then output to the rendered page as follows, assumin | ||||
|  | ||||
| {{< output file="/blog/greatest-city/index.html" >}} | ||||
| <header> | ||||
|     <h1>The World's Greatest City</h1> | ||||
|     <div><a href="/locations/chicago-il/">Chicago IL</a></div> | ||||
|     <h1>The World's Greatest City</h1> | ||||
|     <div><a href="/locations/chicago-il">Chicago IL</a></div> | ||||
|     <ul> | ||||
|         <li> | ||||
|             <a href="/tags/pizza">pizza</a> | ||||
| @@ -70,4 +70,5 @@ The preceding partial would then output to the rendered page as follows, assumin | ||||
| {{< /output >}} | ||||
|  | ||||
|  | ||||
|  | ||||
| [singletemplate]: /templates/single-page-templates/ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user