{"id":"74c1c28316ea6932","repo":"gohugoio/hugo","slug":"failed-to-load-git-data-w","errorCode":null,"errorMessage":"failed to load Git data: %w","messagePattern":"failed to load Git data: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/page__new.go","lineNumber":90,"sourceCode":"\t\t\tShortcodeInfoProvider:      page.NopPage,\n\t\t\tLanguageProvider:           s,\n\t\t\tRelatedDocsHandlerProvider: s,\n\t\t\tm:                          m,\n\t\t\ts:                          s,\n\t\t},\n\t}\n\n\tif ps.IsHome() && ps.PathInfo().IsLeafBundle() {\n\t\tmsg := \"Using %s in your content's root directory is usually incorrect for your home page. \"\n\t\tmsg += \"You should use %s instead. If you don't rename this file, your home page will be \"\n\t\tmsg += \"treated as a leaf bundle, meaning it won't be able to have any child pages or sections.\"\n\t\tps.s.Log.Warnidf(constants.WarnHomePageIsLeafBundle, msg, ps.PathInfo().PathNoLeadingSlash(), strings.ReplaceAll(ps.PathInfo().PathNoLeadingSlash(), \"index\", \"_index\"))\n\t}\n\n\tif m.f != nil {\n\t\tgi, err := s.h.gitInfoForPage(ps)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to load Git data: %w\", err)\n\t\t}\n\t\tps.gitInfo = gi\n\t\towners, err := s.h.codeownersForPage(ps)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to load CODEOWNERS: %w\", err)\n\t\t}\n\t\tps.codeowners = owners\n\t}\n\n\tps.pageMenus = &pageMenus{p: ps}\n\tps.PageMenusProvider = ps.pageMenus\n\tps.GetPageProvider = pageSiteAdapter{s: s, p: ps}\n\tps.GitInfoProvider = ps\n\tps.TranslationsProvider = ps\n\tps.ResourceDataProvider = newDataFunc(ps)\n\tps.RawContentProvider = ps\n\tps.ChildCareProvider = ps\n\tps.TreeProvider = pageTree{p: ps}","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/page__new.go#L72-L108","documentation":"When `enableGitInfo` is active, Hugo attaches per-file Git metadata (last commit, author, date) to each page during page construction (`newPageFromMeta`). If `gitInfoForPage` fails — typically because the git log for the content file cannot be read or parsed — page creation aborts with this wrapped error.","triggerScenarios":"Building with `enableGitInfo = true` (or `--enableGitInfo`) when the working directory is not a usable git repository for the content file: `git` history is unavailable for the file's path, the gitmap scan of `git log` fails, or the repo state is unreadable at build time.","commonSituations":"CI systems doing shallow clones (`fetch-depth: 1` in GitHub Actions) so history is incomplete or the `.git` dir is absent in the build container; content mounted from outside the repo; Docker builds that copy sources without `.git`; submodule or worktree setups where the content path isn't covered by the repo.","solutions":["In CI, fetch full history — e.g. GitHub Actions `actions/checkout` with `fetch-depth: 0` — and ensure `.git` is present in the build context.","Verify `git log -- <content-file>` works from the project root the build runs in.","If Git metadata isn't needed in that environment, disable it: remove `enableGitInfo = true` or drop the `--enableGitInfo` flag for that build."],"exampleFix":"# before (.github/workflows/build.yml)\n- uses: actions/checkout@v4\n# after\n- uses: actions/checkout@v4\n  with:\n    fetch-depth: 0","handlingStrategy":"validation","validationCode":"# Before enabling enableGitInfo = true, verify the site is a real, non-shallow repo:\ngit -C ./site rev-parse --is-inside-work-tree\ngit -C ./site rev-parse --is-shallow-repository # must be false","typeGuard":null,"tryCatchPattern":"if err := build(); err != nil {\n    if strings.Contains(err.Error(), \"failed to load Git data\") {\n        log.Println(\"disable enableGitInfo or fetch full git history (fetch-depth: 0 in CI)\")\n    }\n    return err\n}","preventionTips":["Only set enableGitInfo=true when building inside a git working tree","In CI, clone with full history (actions/checkout fetch-depth: 0) so git log works per file","Ensure the git binary is on PATH in the build environment","Don't build from exported tarballs/artifacts with GitInfo enabled"],"tags":["hugo","git","gitinfo","ci"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}