{"id":"919f3da5aabc9306","repo":"gohugoio/hugo","slug":"abort-jekyll-root-contains-neither-posts-nor-draf","errorCode":null,"errorMessage":"abort: jekyll root contains neither posts nor drafts","messagePattern":"abort: jekyll root contains neither posts nor drafts","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/import.go","lineNumber":419,"sourceCode":"\tif err != nil {\n\t\treturn newUserError(\"path error:\", args[0])\n\t}\n\n\ttargetDir, err := filepath.Abs(filepath.Clean(args[1]))\n\tif err != nil {\n\t\treturn newUserError(\"path error:\", args[1])\n\t}\n\n\tc.r.Println(\"Import Jekyll from:\", jekyllRoot, \"to:\", targetDir)\n\n\tif strings.HasPrefix(filepath.Dir(targetDir), jekyllRoot) {\n\t\treturn newUserError(\"abort: target path should not be inside the Jekyll root\")\n\t}\n\n\tfs := afero.NewOsFs()\n\tjekyllPostDirs, hasAnyPost := c.getJekyllDirInfo(fs, jekyllRoot)\n\tif !hasAnyPost {\n\t\treturn errors.New(\"abort: jekyll root contains neither posts nor drafts\")\n\t}\n\n\terr = c.createProjectFromJekyll(jekyllRoot, targetDir, jekyllPostDirs)\n\tif err != nil {\n\t\treturn newUserError(err)\n\t}\n\n\tc.r.Println(\"Importing...\")\n\n\tfileCount := 0\n\tcallback := func(ctx context.Context, path string, fi hugofs.FileMetaInfo) error {\n\t\tif fi.IsDir() {\n\t\t\treturn nil\n\t\t}\n\n\t\trelPath, err := filepath.Rel(jekyllRoot, path)\n\t\tif err != nil {\n\t\t\treturn newUserError(\"get rel path error:\", path)","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/commands/import.go#L401-L437","documentation":"Returned by `importFromJekyll` after `getJekyllDirInfo` scans the given Jekyll root and finds no `_posts` or `_drafts` directories containing posts. Hugo refuses to proceed because with nothing to import, the specified root is almost certainly wrong, and continuing would create an empty site.","triggerScenarios":"`hugo import jekyll <jekyllRoot> <target>` where `jekyllRoot` (or its collections dirs) contains no `_posts`/`_drafts` directories with any files — typically because the wrong path was passed.","commonSituations":"Pointing the command at the repo root instead of the subdirectory holding the Jekyll site, at the generated `_site` output directory, at a site using only custom collections, or a typo in the path.","solutions":["Verify the first argument points at the directory that actually contains `_posts` (run `ls <jekyllRoot>` and confirm `_posts` or `_drafts` exists).","If the site lives in a subdirectory (e.g. `docs/`), pass that subdirectory as the Jekyll root.","If posts live only in custom collections, move or symlink them under `_posts` before importing, or migrate those files manually."],"exampleFix":"# before\nhugo import jekyll ./myrepo ./newsite\n# after (site lives in docs/)\nhugo import jekyll ./myrepo/docs ./newsite","handlingStrategy":"validation","validationCode":"// Confirm the Jekyll root has posts before invoking import\nhasPosts := false\nfor _, d := range []string{\"_posts\", \"_drafts\"} {\n    if fi, err := os.Stat(filepath.Join(jekyllRoot, d)); err == nil && fi.IsDir() {\n        hasPosts = true\n    }\n}\nif !hasPosts {\n    return errors.New(\"not a Jekyll site root: no _posts or _drafts\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Point the importer at the Jekyll site root (the directory containing _config.yml and _posts), not a subdirectory","Verify _posts/_drafts exist and are directories, not symlinks to missing targets","Check that collections-based sites are restructured, since only _posts/_drafts are detected"],"tags":["hugo","jekyll-import","cli","path"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}