{"record":{"id":"9d2df9655807b1f2","repo":"gohugoio/hugo","slug":"pageoutput-is-nil-for-output-idx-d","errorCode":null,"errorMessage":"pageOutput is nil for output idx %d","messagePattern":"pageOutput is nil for output idx (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/page.go","lineNumber":886,"sourceCode":"\treturn ps.posFromInput(ps.m.content.mustSource(), offset)\n}\n\n// shiftToOutputFormat is serialized. The output format idx refers to the\n// full set of output formats for all sites.\n// This is serialized.\nfunc (ps *pageState) shiftToOutputFormat(isRenderingSite bool, idx int) error {\n\tif err := ps.initPage(); err != nil {\n\t\treturn err\n\t}\n\n\tif len(ps.pageOutputs) == 1 {\n\t\tidx = 0\n\t}\n\n\tps.pageOutputIdx = idx\n\tps.pageOutput = ps.pageOutputs[idx]\n\tif ps.pageOutput == nil {\n\t\tpanic(fmt.Sprintf(\"pageOutput is nil for output idx %d\", idx))\n\t}\n\n\t// Reset any built paginator. This will trigger when re-rendering pages in\n\t// server mode.\n\tif isRenderingSite && ps.pageOutput.paginator != nil && ps.pageOutput.paginator.current != nil {\n\t\tps.pageOutput.paginator.reset()\n\t}\n\n\tif isRenderingSite {\n\t\tcp := ps.pageOutput.pco\n\t\tif cp == nil && ps.canReusePageOutputContent() {\n\t\t\t// Look for content to reuse.\n\t\t\tfor i := range ps.pageOutputs {\n\t\t\t\tif i == idx {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tpo := ps.pageOutputs[i]\n","sourceCodeStart":868,"sourceCodeEnd":904,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/page.go#L868-L904","documentation":"Panic in shiftToOutputFormat: after setting ps.pageOutputIdx = idx, the looked-up ps.pageOutputs[idx] is nil. This means the page's output-format slots contain a nil at the requested index, signalling that the page outputs array was built incompletely or the index is out of sync with available outputs.","triggerScenarios":"Rendering a page for output index idx when the pageOutputs slice has a nil at that position. Happens when output formats are configured/filtered such that a slot is allocated but not populated, or when the global output index passed in does not match the page's own outputs.","commonSituations":"Multi-output/multilingual setups where output-format indexing drifts. A custom output format configuration with gaps. A bug in how the global vs per-page output indices align (often after an outputs config change). Incremental build staleness.","solutions":["Clean-rebuild to discard stale per-page output state.","Review [outputs] configuration per page kind and language; remove unused/gap-inducing formats.","Upgrade Hugo; report the idx value and page path if it reproduces."],"exampleFix":"# before: outputs config leaves an empty slot mid-slice\n[outputs]\nhome = ['html']\npage = ['html', '', 'rss']\n\n# after: contiguous valid formats only\n[outputs]\nhome = ['html','rss']\npage = ['html','rss']","handlingStrategy":"validation","validationCode":"// Keep [outputs] contiguous and valid per kind/language; clean-rebuild to discard stale slots.\n// hugo.toml example:\n//   [outputs]\n//   home = ['html','rss']\n//   page = ['html']","typeGuard":null,"tryCatchPattern":"// Wrap Build in recover() to surface the failing idx cleanly (see 781).","preventionTips":["Avoid gaps in [outputs] configuration.","Clean-rebuild after changing outputs.","Upgrade Hugo.","Report the idx and page path upstream."],"tags":["pages","output-formats","rendering","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"}