{"record":{"id":"74f4009852cbf794","repo":"gohugoio/hugo","slug":"cannot-use-rendertomemory-with-destination","errorCode":null,"errorMessage":"cannot use --renderToMemory with --destination","messagePattern":"cannot use --renderToMemory with --destination","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/server.go","lineNumber":603,"sourceCode":"\n\t\t\tif err := c.setServerInfoInConfig(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif !reloaded && c.fastRenderMode {\n\t\t\t\tc.withConf(func(conf *commonConfig) {\n\t\t\t\t\tconf.fs.PublishDir = hugofs.NewHashingFs(conf.fs.PublishDir, c.changeDetector)\n\t\t\t\t\tconf.fs.PublishDirStatic = hugofs.NewHashingFs(conf.fs.PublishDirStatic, c.changeDetector)\n\t\t\t\t})\n\t\t\t}\n\n\t\t\treturn nil\n\t\t},\n\t)\n\n\tdestinationFlag := cd.CobraCommand.Flags().Lookup(\"destination\")\n\tif c.r.renderToMemory && (destinationFlag != nil && destinationFlag.Changed) {\n\t\treturn fmt.Errorf(\"cannot use --renderToMemory with --destination\")\n\t}\n\tc.doLiveReload = !c.disableLiveReload\n\tc.fastRenderMode = !c.disableFastRender\n\tc.showErrorInBrowser = c.doLiveReload && !c.disableBrowserError\n\n\tif c.fastRenderMode {\n\t\t// For now, fast render mode only. It should, however, be fast enough\n\t\t// for the full variant, too.\n\t\tc.changeDetector = &fileChangeDetector{\n\t\t\t// We use this detector to decide to do a Hot reload of a single path or not.\n\t\t\t// We need to filter out source maps and possibly some other to be able\n\t\t\t// to make that decision.\n\t\t\tirrelevantRe: regexp.MustCompile(`\\.map$`),\n\t\t}\n\n\t\tc.changeDetector.PrepareNew()\n\n\t}","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/server.go#L585-L621","documentation":"`hugo server` rejects a mutually exclusive flag combination: in-memory rendering (`--renderToMemory`) cannot coexist with an explicit `--destination`, because rendering to memory implies no on-disk output. The check reads both flags and returns a plain (unformatted) error.","triggerScenarios":"Fires when `c.r.renderToMemory` is true AND the `destination` cobra flag exists and was explicitly set (`destinationFlag.Changed`).","commonSituations":"A developer copies `--renderToMemory` from a CI snippet while also passing `-d public`; mixing `server` flags intended for different workflows; alias scripts that always set both flags.","solutions":["Remove `--renderToMemory` when you need output written to `--destination`.","Remove `--destination` when you want the memory-only server (the default for `hugo server`).","Audit your wrapper script/alias for conflicting inherited flags."],"exampleFix":"// before\n// $ hugo server --renderToMemory --destination=public\n// after\n// $ hugo server --renderToMemory","handlingStrategy":"validation","validationCode":"// Reject the conflicting flag pair before invoking Hugo.\nfunc validateServerFlags(renderToMemory bool, destinationChanged bool) error {\n  if renderToMemory && destinationChanged {\n    return fmt.Errorf(\"cannot use --renderToMemory with --destination\")\n  }\n  return nil\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Decide your server output strategy up front: memory OR on-disk destination.","Audit aliases/wrapper scripts that combine flags from different workflows.","Remember `hugo server` defaults to in-memory rendering — don't add `-d` unless needed."],"tags":["hugo","server","configuration","flags"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}