diff --git a/hugolib/gitinfo.go b/hugolib/gitinfo.go index d356fcf075e..bbcdbda181e 100644 --- a/hugolib/gitinfo.go +++ b/hugolib/gitinfo.go @@ -38,9 +38,9 @@ func (g *gitInfo) forPage(p *Page) (*gitmap.GitInfo, bool) { } func newGitInfo(cfg config.Provider) (*gitInfo, error) { - workingDir := cfg.GetString("workingDir") + contentDir := cfg.GetString("contentDir") - gitRepo, err := gitmap.Map(workingDir, "") + gitRepo, err := gitmap.Map(contentDir, "") if err != nil { return nil, err } diff --git a/hugolib/page_test.go b/hugolib/page_test.go index 9723b1426cf..cc8272492b8 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -896,6 +896,10 @@ func TestPageWithLastmodFromGitInfo(t *testing.T) { wd, err := os.Getwd() assrt.NoError(err) cfg.Set("workingDir", filepath.Join(wd, "testsite")) + // Content is actually read from the contentDirs specified in langConfig + // above. Set global contentDir to a common parent, as this is + // where Hugo will look for GitInfo. + cfg.Set("contentDir", filepath.Join(wd, "testsite")) h, err := NewHugoSites(deps.DepsCfg{Fs: fs, Cfg: cfg})