Files
hugo/content/extras/gitinfo.md
T
Bjørn Erik Pedersen 37c69054e2 Squashed 'docs/' changes from 5d9a6703..f3c88b08
f3c88b08 Add warning on GitInfo and Shallow Clones
fa5be591 Make the two common Taxonomy templates explicit
4a81c507 Update pull request link in showcase.html
f751e57a Update christianmendoza.me in the showcase
d582419b Remove commit message prefix from showcase addition guide
d12791cf Fix path for screenshot in showcase addition guide
e487b916 Add invincible.site to the showcase
c85cfccf Update guide for showcase additions
c44b31c1 Fix spelling
dc10d7f6 Add slightly better GitHub install description
2611980f Revert "Add workaround to Fetch from GitHub documentation"
b2e56907 Fix Git commit link in footer
b025a638 Regenerate commands docs for v0.24.1
0741ad08 Update README.md
942d130a Add branch info to README
e8c36390 Set hugoDocs/master to 0.24.1
c4e21471 Add workaround to Fetch from GitHub documentation
db0a3c08 Fix typo in release note

git-subtree-dir: docs
git-subtree-split: f3c88b0810
2017-07-06 10:25:46 +02:00

1.8 KiB

aliases, lastmod, date, menu, next, prev, title
aliases lastmod date menu next prev title
/doc/gitinfo/
2016-12-11 2016-12-11
main
parent
extras
/extras/livereload /extras/datadrivencontent GitInfo

Hugo provides a way to integrate Git data into your site.

Prerequisites

  1. The Hugo site must be in a Git-enabled directory.
  2. The Git executable must be installed and in your system PATH.
  3. Enable the GitInfo feature in Hugo by using --enableGitInfo on the command line or by setting enableGitInfo to true in your site configuration.

The GitInfo Object

The GitInfo object contains the following fields:

AbbreviatedHash
abbreviated commit hash, e.g. 866cbcc
AuthorName
author name, respecting .mailmap
AuthorEmail
author email address, respecting .mailmap
AuthorDate
the author date
Hash
commit hash, e.g. 866cbccdab588b9908887ffd3b4f2667e94090c3
Subject
commit message subject, e.g. tpl: Add custom index function

Other Considerations

The Git integrations should be fairly performant, but it does add some time to the build, which depends somewhat on the Git history size.

The accuracy of data depends on the underlying local git respository. If the local repository is a shallow clone, then any file that hasn't been modified in the truncated history will default to data in the oldest commit. In particular, if the respository has been cloned using --depth=1 then every file will the exact same GitInfo data -- that of the only commit in the repository.

In particular, many CI/CD systems such as travis-ci.org default to a clone depth of 50 which is unlikely to be deep enough. You can explicitly add back the missing history using using git fetch --unshallow or make the initial checkout deeper.