mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
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:
committed by
GitHub
parent
186db7cd7a
commit
e8380e612f
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user