{"record":{"id":"8db6076b21d8260f","repo":"gohugoio/hugo","slug":"pagemeta-pagemetasource-pi-must-be-set-before-crea","errorCode":null,"errorMessage":"pageMeta.pageMetaSource.pi must be set before creating cachedContent","messagePattern":"pageMeta\\.pageMetaSource\\.pi must be set before creating cachedContent","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"hugolib/page__content.go","lineNumber":110,"sourceCode":"\t\t\tNoFrontMatter: m.noFrontMatter,\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tm.pi.itemsStep1 = items\n\n\tif err := m.pi.parseSource(source, m.noFrontMatter); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc (m *pageMeta) newCachedContent(s *Site) (*cachedContent, error) {\n\tif m.pageMetaSource.pi == nil {\n\t\tpanic(\"pageMeta.pageMetaSource.pi must be set before creating cachedContent\")\n\t}\n\n\tc := &cachedContent{\n\t\tpm:          s.pageMap,\n\t\tStaleInfo:   m,\n\t\tpi:          m.pi,\n\t\tenableEmoji: s.conf.EnableEmoji,\n\t\tscopes:      hmaps.NewCache[string, *cachedContentScope](),\n\t}\n\tvar hasName predicate.P[string] = m.pi.shortcodeParseInfo.hasName\n\tc.hasShortcode.Store(&hasName)\n\n\treturn c, nil\n}\n\n// Content cached for a page instance.\ntype cachedContent struct {\n\tpm *pageMap","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/page__content.go#L92-L128","documentation":"Panic in pageMeta.newCachedContent when m.pageMetaSource.pi (the page parser / parse info) is nil. cachedContent needs the parsed source to build content scopes and shortcode metadata, so the parser must be initialized first. The message states the required ordering explicitly: pi must be set before creating cachedContent.","triggerScenarios":"Calling newCachedContent before the page's source parser (pageMetaSource.pi) was assigned. Reordering in a fork that creates cachedContent too early. A page-construction path that skips parse-source setup. An internal ordering regression.","commonSituations":"Forking Hugo and changing page initialization order. A bug after refactoring page-meta construction. Headless/content-adapter pages built without running the parse step.","solutions":["Ensure the page's parser (pi) is initialized (e.g. via the parse-source step) before any cachedContent creation.","Use the standard page-meta construction sequence; do not reorder init steps.","Upgrade Hugo; report with a reproducer if hit on stock Hugo."],"exampleFix":"// before (fork): cachedContent created before parser\nm.newCachedContent(s) // pi is nil\n\n// after\nm.pageMetaSource.pi = newPageParseInfo(...)\nm.parseSource(source, false)\nm.newCachedContent(s)","handlingStrategy":"validation","validationCode":"// Internal ordering invariant: initialize the page parser (pi) before newCachedContent.\n// In a fork, run parseSource first:\n//   m.pageMetaSource.pi = newPageParseInfo(...)\n//   m.parseSource(source, false)\n//   m.newCachedContent(s)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not reorder page-meta initialization.","Always run the parse step before cachedContent creation.","Use standard page construction.","Report stock-Hugo reproducers upstream."],"tags":["pages","content","parser","panic","internal-invariant"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}