diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-05-04 09:44:59 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-05-04 09:44:59 +0200 |
commit | 914cc85e22af2e6c28f24a5fc70de94e4b9f1b1b (patch) | |
tree | e7b5fcc856003415c613312c80ba2f301eeae03c /docs/content/en/functions | |
parent | a6816db77574ba3d48a6414c97a53a691c34e705 (diff) | |
parent | 83bef6955e014d40c0f00db9cebe09113154e999 (diff) |
Merge commit '83bef6955e014d40c0f00db9cebe09113154e999'
Diffstat (limited to 'docs/content/en/functions')
107 files changed, 4197 insertions, 0 deletions
diff --git a/docs/content/en/functions/GetPage.md b/docs/content/en/functions/GetPage.md new file mode 100644 index 000000000..1a8a51c13 --- /dev/null +++ b/docs/content/en/functions/GetPage.md @@ -0,0 +1,82 @@ +--- +title: .GetPage +description: "Gets a `Page` of a given `Kind` and `path`." +godocref: +date: 2017-02-01 +publishdate: 2017-02-01 +lastmod: 2017-02-01 +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [sections,lists,indexes] +signature: [".GetPage KIND PATH"] +workson: [] +hugoversion: +relatedfuncs: [] +deprecated: false +aliases: [] +--- + +Every `Page` has a [`Kind` attribute][page_kinds] that shows what kind of page it is. While this attribute can be used to list pages of a certain `kind` using `where`, often it can be useful to fetch a single page by its path. + +`.GetPage` returns a page of a given `Kind` and `path`. + +{{% note %}} +If the `path` is `"foo/bar.md"`, it can be written as exactly that, or broken up +into multiple strings as `"foo" "bar.md"`. +{{% /note %}} + +``` +{{ with .Site.GetPage "section" "blog" }}{{ .Title }}{{ end }} +``` + +This method wil return `nil` when no page could be found, so the above will not print anything if the blog section is not found. + +For a regular page (whose `Kind` is `page`): + |