From 62d7b269fbe7aae608677fd684cd8d48200aaa8a Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Wed, 4 Oct 2017 10:29:02 -0400 Subject: [PATCH] Clarify that .Lastmod automatically uses .GitInfo.AuthorDate (#226) If the `lastmod` field in the content front matter is not set if `.GitInfo` is enabled, Page's .Lastmod is auto-set to .GitInfo.AuthorDate. --- content/variables/git.md | 4 ++++ content/variables/page.md | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/content/variables/git.md b/content/variables/git.md index 6ed752dad..a06ee104c 100644 --- a/content/variables/git.md +++ b/content/variables/git.md @@ -51,4 +51,8 @@ The `GitInfo` object contains the following fields: `.Subject` : commit message subject (e.g., `tpl: Add custom index function`) +## `.Lastmod` + +If the `.GitInfo` feature is enabled, **and** if the `lastmod` field in the content's front matter is not set, `.Lastmod` (on `Page`) is fetched from Git i.e. `.GitInfo.AuthorDate`. + [configuration]: /getting-started/configuration/ diff --git a/content/variables/page.md b/content/variables/page.md index 0e1313bbd..b813fc8e8 100644 --- a/content/variables/page.md +++ b/content/variables/page.md @@ -79,7 +79,12 @@ See [`.Scratch`](/functions/scratch/) for page-scoped, writable variables. `config`. `.Lastmod` -: the date the content was last modified; `.Lastmod` pulls from the `lastmod` field in a content's front matter. If `lastmod` is not set, Hugo will default to the `date` field. See also `.ExpiryDate`, `.Date`, and `.PublishDate`. +: the date the content was last modified. `.Lastmod` pulls from the `lastmod` field in a content's front matter. + + - If `lastmod` is not set, and `.GitInfo` feature is disabled, the front matter `date` field will be used. + - If `lastmod` is not set, and `.GitInfo` feature is enabled, `.GitInfo.AuthorDate` will be used instead. + +See also `.ExpiryDate`, `.Date`, `.PublishDate`, and [`.GitInfo`][gitinfo]. `.LinkTitle` : access when creating links to the content. If set, Hugo will use the `linktitle` from the front matter before `title`. @@ -266,3 +271,5 @@ The top-level key will be preferred. Therefore, the following method, when appli {{ $.Param "favorites.flavor" }} => vanilla ``` + +[gitinfo]: /variables/git/