{"record":{"id":"c1bd600976181973","repo":"gohugoio/hugo","slug":"path-already-exists","errorCode":null,"errorMessage":"{path} already exists","messagePattern":"(.+?) already exists","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"create/skeletons/skeletons.go","lineNumber":118,"sourceCode":"\t\t}\n\n\t\tisEmpty, _ := helpers.IsEmpty(createpath, sourceFs)\n\n\t\tswitch {\n\t\tcase !isEmpty && !force:\n\t\t\treturn errors.New(createpath + \" already exists and is not empty. See --force.\")\n\t\tcase !isEmpty && force:\n\t\t\tvar all []string\n\t\t\tfs.WalkDir(projectFs, \".\", func(path string, d fs.DirEntry, err error) error {\n\t\t\t\tif d.IsDir() && path != \".\" {\n\t\t\t\t\tall = append(all, path)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\tall = append(all, filepath.Join(createpath, \"hugo.\"+format))\n\t\t\tfor _, path := range all {\n\t\t\t\tif exists, _ := helpers.Exists(path, sourceFs); exists {\n\t\t\t\t\treturn errors.New(path + \" already exists\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprojectConfig := map[string]any{\n\t\t\"baseURL\": \"https://example.org/\",\n\t\t\"locale\":  \"en-us\",\n\t\t\"title\":   \"My New Hugo Project\",\n\t}\n\n\terr := createProjectConfig(sourceFs, createpath, projectConfig, format)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefaultArchetype := map[string]any{\n\t\t\"title\": \"{{ replace .File.ContentBaseName \\\"-\\\" \\\" \\\" | title }}\",","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/create/skeletons/skeletons.go#L100-L136","documentation":"Even with --force, CreateProject pre-checks each file the skeleton would write and refuses to overwrite any that already exists. The offending path is named in the error message. This protects configured files (e.g. hugo.toml, archetype files) from being silently destroyed.","triggerScenarios":"`hugo new site . --force` where one of the skeleton files (such as hugo.<format> or a file under the scaffold) already exists in the target.","commonSituations":"Re-scaffolding over a project that already has a hugo.toml or default archetype; partial previous scaffold left files behind.","solutions":["Rename or remove the specific file named in the error message.","Manually merge the scaffolded content instead of overwriting.","Scaffold into a fresh directory and copy files in selectively."],"exampleFix":"// before\nhugo new site . --force   # hugo.toml exists\n// after\nmv hugo.toml hugo.toml.bak\nhugo new site . --force","handlingStrategy":"validation","validationCode":"// Pre-check skeleton files before forcing a scaffold\nfor _, p := range skeletonFiles {\n    if _, err := os.Stat(filepath.Join(createpath, p)); err == nil {\n        return fmt.Errorf(\"%s already exists; rename or remove it\", p)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Even with --force, read the message to find the conflicting file.","Backup configured files (hugo.toml, archetypes) before forcing.","Scaffold into a clean directory and merge selectively."],"tags":["hugo","cli","filesystem","scaffold"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}