diff --git a/docs/content/en/variables/git.md b/docs/content/en/variables/git.md index 59ee9ac889e..acfd17c11b8 100644 --- a/docs/content/en/variables/git.md +++ b/docs/content/en/variables/git.md @@ -25,7 +25,7 @@ Hugo's Git integrations should be fairly performant but *can* increase your buil ## `.GitInfo` Prerequisites -1. The Hugo site must be in a Git-enabled directory. +1. The global `contentDir` must be in a Git-enabled directory. Any language-specific `contentDir` must be in the same repo as the global `contentDir`. 2. The Git executable must be installed and in your system `PATH`. 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]. diff --git a/hugolib/gitinfo.go b/hugolib/gitinfo.go index 6acc47d173f..fc574a77f5a 100644 --- a/hugolib/gitinfo.go +++ b/hugolib/gitinfo.go @@ -36,9 +36,12 @@ func (g *gitInfo) forPage(p page.Page) *gitmap.GitInfo { } func newGitInfo(cfg config.Provider) (*gitInfo, error) { - workingDir := cfg.GetString("workingDir") + contentDir := cfg.GetString("contentDir") + if !filepath.IsAbs(contentDir) { + contentDir = filepath.Join(cfg.GetString("workingDir"), contentDir) + } - gitRepo, err := gitmap.Map(workingDir, "") + gitRepo, err := gitmap.Map(contentDir, "") if err != nil { return nil, err }