Add GitInfo

This commit adds a `GitInfo` object to `Page` if `EnableGitInfo` is set.

It then also sets `Lastmod` for the given `Page` to the author date provided by Git.

The Git integrations should be fairly performant, but it adds "some time" to the build, somewhat depending on the Git history size.

If you want, you can run without during development and turn it on when deploying to the live server: `hugo --enableGitInfo`.

Fixes #2102
This commit is contained in:
Bjørn Erik Pedersen 2016-11-01 23:04:12 +01:00 committed by GitHub
parent b9a3b7aec0
commit cf6198aa19
2 changed files with 2 additions and 1 deletions

View File

@ -2,6 +2,7 @@ title = "Hugo: A Fast and Flexible Website Generator"
baseurl = "http://gohugo.io/"
MetaDataFormat = "yaml"
pluralizeListTitles = false
enableGitInfo = true
[blackfriday]
plainIDAnchors = true

View File

@ -1,6 +1,6 @@
<div class="row">
<div class="footer-panel">
<p>Last revision: {{ .Lastmod.Format "January 2, 2006" }}
<p>Last revision: {{ .Lastmod.Format "January 2, 2006" }}{{ if .IsPage }}<em>{{ with .GitInfo }}| {{ .Subject }} | {{ .AbbreviatedHash }}{{end }}</em>{{ end }}
<span style="float: right;">Hugo v{{ .Hugo.Version }} documentation</span>
</p>
</div>