{"id":"bc89f999b3faece9","repo":"gohugoio/hugo","slug":"failed-to-save-file-q-s","errorCode":null,"errorMessage":"failed to save file %q: %s","messagePattern":"failed to save file %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/import.go","lineNumber":337,"sourceCode":"\t\treturn err\n\t}\n\tpf, err := pageparser.ParseFrontMatterAndContent(bytes.NewReader(contentBytes))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to parse file %q: %s\", filename, err)\n\t}\n\tnewmetadata, err := c.convertJekyllMetaData(pf.FrontMatter, postName, postDate, draft)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to convert metadata for file %q: %s\", filename, err)\n\t}\n\n\tcontent, err := c.convertJekyllContent(newmetadata, string(pf.Content))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to convert content for file %q: %s\", filename, err)\n\t}\n\n\tfs := hugofs.Os\n\tif err := helpers.WriteToDisk(targetFile, strings.NewReader(content), fs); err != nil {\n\t\treturn fmt.Errorf(\"failed to save file %q: %s\", filename, err)\n\t}\n\treturn nil\n}\n\nfunc (c *importCommand) copyJekyllFilesAndFolders(jekyllRoot, dest string, jekyllPostDirs map[string]bool) (err error) {\n\tfs := hugofs.Os\n\n\tfi, err := fs.Stat(jekyllRoot)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !fi.IsDir() {\n\t\treturn errors.New(jekyllRoot + \" is not a directory\")\n\t}\n\terr = os.MkdirAll(dest, fi.Mode())\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/commands/import.go#L319-L355","documentation":"Emitted in `convertJekyllPost` when `helpers.WriteToDisk` fails writing the converted post to the target Hugo content directory. Conversion succeeded; the failure is at the filesystem write step, so the error is almost always an OS-level I/O or permission problem rather than a content problem.","triggerScenarios":"`hugo import jekyll` writing the converted file to `<targetDir>/<relPath>` fails — e.g. the target directory is not writable, the disk is full, the path exceeds OS limits, or the filename contains characters invalid on the target filesystem (e.g. `:` on Windows).","commonSituations":"Importing into a read-only or root-owned directory, running on Windows with Jekyll filenames containing characters illegal in NTFS, network/overlay filesystems, or out-of-space containers.","solutions":["Check write permissions on the target directory and its parents; run the import as a user that can write there.","Verify free disk space and that the target path is on a writable filesystem.","On Windows, rename source posts whose filenames contain characters invalid on the target filesystem, then re-run."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify target dir exists and is writable before import\nif err := os.MkdirAll(targetDir, 0o755); err != nil {\n    return fmt.Errorf(\"target not writable: %w\", err)\n}\nif f, err := os.CreateTemp(targetDir, \".probe\"); err != nil {\n    return err\n} else { f.Close(); os.Remove(f.Name()) }","typeGuard":null,"tryCatchPattern":"if err := saveFile(dst, content); err != nil {\n    if errors.Is(err, fs.ErrPermission) {\n        // fix permissions / choose another target dir\n    }\n    return err\n}","preventionTips":["Check disk space and directory permissions on the target before importing","Never import into a directory owned by another user or a read-only mount","Use a fresh empty target directory so name collisions can't occur"],"tags":["hugo","jekyll-import","filesystem","permissions"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}