gohugoio/hugo · error
abort: jekyll root contains neither posts nor drafts
Error message
abort: jekyll root contains neither posts nor drafts
What it means
importFromJekyll walks the Jekyll root via getJekyllDirInfo to find post directories; if hasAnyPost is false (no post directory contained any posts or drafts), the import aborts because there is nothing to import (import.go:417-420).
Solutions
- Verify the Jekyll root contains _posts (and optionally _drafts) with post files
- Point the import at the real Jekyll site root
- Ensure post files exist and are readable
Example fix
# before hugo import jekyll ~/empty-dir ./out # after (point at the real Jekyll root) hugo import jekyll ~/my-jekyll-site ./out
Defensive patterns
Strategy: validation
Validate before calling
if _, hasAnyPost := getJekyllDirInfo(fs, root); !hasAnyPost {
return errors.New("no posts/drafts found in Jekyll root")
} Prevention
- Confirm _posts is populated before importing
- Run the import against the actual Jekyll site root
When it happens
Trigger: `hugo import jekyll <root> <target>` where <root> has no _posts or _drafts containing valid posts, or the post dirs are empty.
Common situations: Pointing at a non-Jekyll directory; a Jekyll root whose _posts is empty; posts named in a way the detector does not recognise.
Related errors
- is not a directory
- target path " " exists and is not empty
- target path " " exists but is not a directory
- filename not match
- failed to convert content for file
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/919f3da5aabc9306.
Report an issue: GitHub.
Appendix: source
Thrown at commands/import.go:419
if err != nil {
return newUserError("path error:", args[0])
}
targetDir, err := filepath.Abs(filepath.Clean(args[1]))
if err != nil {
return newUserError("path error:", args[1])
}
c.r.Println("Import Jekyll from:", jekyllRoot, "to:", targetDir)
if strings.HasPrefix(filepath.Dir(targetDir), jekyllRoot) {
return newUserError("abort: target path should not be inside the Jekyll root")
}
fs := afero.NewOsFs()
jekyllPostDirs, hasAnyPost := c.getJekyllDirInfo(fs, jekyllRoot)
if !hasAnyPost {
return errors.New("abort: jekyll root contains neither posts nor drafts")
}
err = c.createProjectFromJekyll(jekyllRoot, targetDir, jekyllPostDirs)
if err != nil {
return newUserError(err)
}
c.r.Println("Importing...")
fileCount := 0
callback := func(ctx context.Context, path string, fi hugofs.FileMetaInfo) error {
if fi.IsDir() {
return nil
}
relPath, err := filepath.Rel(jekyllRoot, path)
if err != nil {
return newUserError("get rel path error:", path)View on GitHub (pinned to 52c9bd7908)