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

  1. Verify the Jekyll root contains _posts (and optionally _drafts) with post files
  2. Point the import at the real Jekyll site root
  3. 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

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


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)