git.md (1807B)
1 ---
2 title: Git Info Variables
3 linktitle: Git Variables
4 description: Get the last Git revision information for every content file.
5 date: 2017-03-12
6 publishdate: 2017-03-12
7 lastmod: 2017-03-12
8 categories: [variables and params]
9 keywords: [git]
10 draft: false
11 menu:
12 docs:
13 parent: "variables"
14 weight: 70
15 weight: 70
16 sections_weight: 70
17 aliases: [/extras/gitinfo/]
18 toc: false
19 wip: false
20 ---
21
22 {{% note "`.GitInfo` Performance Considerations" %}}
23 Hugo's Git integrations should be fairly performant but *can* increase your build time. This will depend on the size of your Git history.
24 {{% /note %}}
25
26 ## `.GitInfo` Prerequisites
27
28 1. The Hugo site must be in a Git-enabled directory.
29 2. The Git executable must be installed and in your system `PATH`.
30 3. The `.GitInfo` feature must be enabled in your Hugo project by passing `--enableGitInfo` flag on the command line or by setting `enableGitInfo` to `true` in your [site's configuration file][configuration].
31
32 ## The `.GitInfo` Object
33
34 The `GitInfo` object contains the following fields:
35
36 .AbbreviatedHash
37 : the abbreviated commit hash (e.g., `866cbcc`)
38
39 .AuthorName
40 : the author's name, respecting [`.mailmap`](https://git-scm.com/docs/gitmailmap)
41
42 .AuthorEmail
43 : the author's email address, respecting [`.mailmap`](https://git-scm.com/docs/gitmailmap)
44
45 .AuthorDate
46 : the author date
47
48 .Hash
49 : the commit hash (e.g., `866cbccdab588b9908887ffd3b4f2667e94090c3`)
50
51 .Subject
52 : commit message subject (e.g., `tpl: Add custom index function`)
53
54 ## `.Lastmod`
55
56 If the `.GitInfo` feature is enabled, `.Lastmod` (on `Page`) is fetched from Git i.e. `.GitInfo.AuthorDate`. This behaviour can be changed by adding your own [front matter configuration for dates](/getting-started/configuration/#configure-front-matter).
57
58 [configuration]: /getting-started/configuration/