{"record":{"id":"4378d48092b3b026","repo":"gohugoio/hugo","slug":"no-site","errorCode":null,"errorMessage":"no site","messagePattern":"no site","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"hugolib/page.go","lineNumber":590,"sourceCode":"\tpages, err := ps.s.pageMap.getOrCreatePagesFromCache(nil, key, func(string) (page.Pages, error) {\n\t\tvar pas page.Pages\n\t\tfor _, pp := range ps.AllTranslations() {\n\t\t\tif !pp.Eq(ps) {\n\t\t\t\tpas = append(pas, pp)\n\t\t\t}\n\t\t}\n\t\treturn pas, nil\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn pages\n}\n\nfunc (ps *pageState) initCommonProviders(pp pagePaths) error {\n\tif ps.IsPage() {\n\t\tif ps.s == nil {\n\t\t\tpanic(\"no site\")\n\t\t}\n\t\tps.posNextPrev = &nextPrev{init: ps.s.init.prevNext}\n\t\tps.posNextPrevSection = &nextPrev{init: ps.s.init.prevNextInSection}\n\t\tps.InSectionPositioner = newPagePositionInSection(ps.posNextPrevSection)\n\t\tps.Positioner = newPagePosition(ps.posNextPrev)\n\t}\n\n\tps.OutputFormatsProvider = pp\n\tps.targetPathDescriptor = pp.targetPathDescriptor\n\tps.RefProvider = newPageRef(ps)\n\tps.SitesProvider = ps.s\n\tps.SiteProvider = ps\n\n\treturn nil\n}\n\n// Exported so it can be used in integration tests.\nfunc (po *pageOutput) GetInternalTemplateBasePathAndDescriptor() (string, tplimpl.TemplateDescriptor) {","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/page.go#L572-L608","documentation":"Panic in initCommonProviders: for a regular page (IsPage()), the pageState's site reference ps.s must be non-nil because next/prev positioners and providers are wired against the site. A nil site means the page was constructed without being attached to a Site, breaking the build's provider setup.","triggerScenarios":"A pageState created without an owning Site (ps.s nil) then passed through initCommonProviders. Manual page construction in a fork or test that omits site assignment. A page-decoding path that failed to bind the site.","commonSituations":"Forking Hugo and constructing pageState directly. Test helpers that build pages without a site. A bug in page collection that drops the site reference (often after a refactor of the page map).","solutions":["Construct pages through the standard page-map/collector APIs which always bind a Site.","In tests, use hugolib integration-test builders that create a proper Site.","If forking, ensure every pageState gets s set at creation time.","Report a Hugo issue with a reproducer if hit on an unmodified build."],"exampleFix":"// before (fork): page created without site\nps := &pageState{Kind: kinds.KindPage}\nps.initCommonProviders(pp) // panic: no site\n\n// after\nps := &pageState{s: site, Kind: kinds.KindPage}\nps.initCommonProviders(pp)","handlingStrategy":"validation","validationCode":"// Internal invariant — ensure pages are created via the page map / collector so the Site is bound.\n// In a fork, assert before initCommonProviders:\n//   if ps.IsPage() && ps.s == nil { return fmt.Errorf(\"page %q has no site\", ps.Path()) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create pages through standard page-map APIs.","Always assign the owning Site when constructing a pageState in forks.","Use hugolib integration-test helpers.","Report stock-Hugo reproducers upstream."],"tags":["pages","site","providers","panic","internal-invariant"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}