mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
112c3c5c04
- `.Ref` and `.RelRef` take a reference (the logical filename for a page, including extension and/or a document fragment ID) and return a permalink (or relative permalink) to the referenced document. - If the reference is a page name (such as `about.md`), the page will be discovered and the permalink will be returned: `/about/` - If the reference is a page name with a fragment (such as `about.md#who`), the page will be discovered and used to add the `page.UniqueID()` to the resulting fragment and permalink: `/about/#who:deadbeef`. - If the reference is a fragment and `.*Ref` has been called from a `Node` or `SiteInfo`, it will be returned as is: `#who`. - If the reference is a fragment and `.*Ref` has been called from a `Page`, it will be returned with the page’s unique ID: `#who:deadbeef`. - `.*Ref` can be called from either `Node`, `SiteInfo` (e.g., `Node.Site`), `Page` objects, or `ShortcodeWithPage` objects in templates. - `.*Ref` cannot be used in content, so two shortcodes have been created to provide the functionality to content: `ref` and `relref`. These are intended to be used within markup, like `[Who]({{% ref about.md#who %}})` or `<a href="{{% ref about.md#who %}}">Who</a>`. - There are also `ref` and `relref` template functions (used to create the shortcodes) that expect a `Page` or `Node` object and the reference string (e.g., `{{ relref . "about.md" }}` or `{{ "about.md" | ref . }}`). It actually looks for `.*Ref` as defined on `Node` or `Page` objects. - Shortcode handling had to use a *differently unique* wrapper in `createShortcodePlaceholder` because of the way that the `ref` and `relref` are intended to be used in content. |
||
---|---|---|
.. | ||
benchmark_test.go | ||
handler_base.go | ||
handler_file.go | ||
handler_meta.go | ||
handler_page.go | ||
menu.go | ||
menu_test.go | ||
node.go | ||
page.go | ||
page_permalink_test.go | ||
page_taxonomy_test.go | ||
page_test.go | ||
page_time_integration_test.go | ||
pageGroup.go | ||
pageGroup_test.go | ||
pageSort.go | ||
pagesPrevNext.go | ||
pagesPrevNext_test.go | ||
path_seperators_test.go | ||
path_seperators_windows_test.go | ||
permalinks.go | ||
permalinks_test.go | ||
planner.go | ||
redis.cn.md | ||
rss_test.go | ||
shortcode.go | ||
shortcode_test.go | ||
shortcodeparser.go | ||
shortcodeparser_test.go | ||
site.go | ||
site_show_plan_test.go | ||
site_test.go | ||
site_url_test.go | ||
siteinfo_test.go | ||
sitemap.go | ||
sitemap_test.go | ||
summary.go | ||
taxonomy.go | ||
taxonomy_test.go |