summaryrefslogtreecommitdiffstats
path: root/commands/hugo.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-11-01 23:04:12 +0100
committerGitHub <noreply@github.com>2016-11-01 23:04:12 +0100
commite8380e612fae18493556d620726a9069a17128db (patch)
treee7aa175227a5748a65b667734bb080a75a43d69e /commands/hugo.go
parent186db7cd7ad56051d5a064ee5120e6ec73f575a0 (diff)
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
Diffstat (limited to 'commands/hugo.go')
-rw-r--r--commands/hugo.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/commands/hugo.go b/commands/hugo.go
index 376438fcb..e93aec563 100644
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -133,6 +133,7 @@ var (
canonifyURLs bool
cleanDestination bool
enableRobotsTXT bool
+ enableGitInfo bool
disable404 bool
disableRSS bool
disableSitemap bool
@@ -237,6 +238,7 @@ func initHugoBuildCommonFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(&uglyURLs, "uglyURLs", false, "if true, use /filename.html instead of /filename/")
cmd.Flags().BoolVar(&canonifyURLs, "canonifyURLs", false, "if true, all relative URLs will be canonicalized using baseURL")
cmd.Flags().StringVarP(&baseURL, "baseURL", "b", "", "hostname (and path) to the root, e.g. http://spf13.com/")
+ cmd.Flags().BoolVar(&enableGitInfo, "enableGitInfo", false, "Add Git revision, date and author info to the pages")
cmd.Flags().BoolVar(&nitro.AnalysisOn, "stepAnalysis", false, "display memory and timing of different steps of the program")
cmd.Flags().BoolVar(&pluralizeListTitles, "pluralizeListTitles", true, "Pluralize titles in lists using inflect")
@@ -319,6 +321,9 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
if flagChanged(cmdV.Flags(), "enableRobotsTXT") {
viper.Set("enableRobotsTXT", enableRobotsTXT)
}
+ if flagChanged(cmdV.Flags(), "enableGitInfo") {
+ viper.Set("enableGitInfo", enableGitInfo)
+ }
if flagChanged(cmdV.Flags(), "pluralizeListTitles") {
viper.Set("pluralizeListTitles", pluralizeListTitles)
}