gohugoio/hugo · error
{jekyllRoot} is not a directory
Error message
{jekyllRoot} is not a directory What it means
In copyJekyllFilesAndFolders, after os.Stat on jekyllRoot, if it is not a directory the import fails because it expects to walk a Jekyll site root directory (import.go:345-351).
Source
Thrown at commands/import.go:350
return fmt.Errorf("failed to convert content for file %q: %s", filename, err)
}
fs := hugofs.Os
if err := helpers.WriteToDisk(targetFile, strings.NewReader(content), fs); err != nil {
return fmt.Errorf("failed to save file %q: %s", filename, err)
}
return nil
}
func (c *importCommand) copyJekyllFilesAndFolders(jekyllRoot, dest string, jekyllPostDirs map[string]bool) (err error) {
fs := hugofs.Os
fi, err := fs.Stat(jekyllRoot)
if err != nil {
return err
}
if !fi.IsDir() {
return errors.New(jekyllRoot + " is not a directory")
}
err = os.MkdirAll(dest, fi.Mode())
if err != nil {
return err
}
entries, err := os.ReadDir(jekyllRoot)
if err != nil {
return err
}
for _, entry := range entries {
sfp := filepath.Join(jekyllRoot, entry.Name())
dfp := filepath.Join(dest, entry.Name())
if entry.IsDir() {
if entry.Name()[0] != '_' && entry.Name()[0] != '.' {
if _, ok := jekyllPostDirs[entry.Name()]; !ok {
err = hugio.CopyDir(fs, sfp, dfp, nil)
if err != nil {View on GitHub (pinned to 52c9bd7908)
Solutions
- Point the first argument at the Jekyll site root directory (the folder containing _posts and _config.yml)
- Verify with `ls <root>` that it is a directory
- Resolve symlinks before passing the path
Example fix
# before hugo import jekyll ~/blog/_config.yml ./out # after hugo import jekyll ~/blog ./out
Defensive patterns
Strategy: validation
Validate before calling
fi, err := os.Stat(root)
if err != nil || !fi.IsDir() {
return errors.New("root must be a directory")
} Prevention
- Always pass the Jekyll site root directory, never an individual file
- Validate the root contains _posts before importing
When it happens
Trigger: `hugo import jekyll <root> <target>` where <root> is a file path, not a directory.
Common situations: Passing a path to _config.yml or a file instead of the Jekyll site root; a broken symlink at the root.
Related errors
- target path "{targetDir}" exists but is not a directory
- target path "{targetDir}" exists and is not empty
- abort: jekyll root contains neither posts nor drafts
- filename not match
- must not be run from the file system root
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/4fd6f3931508940b.
Report an issue: GitHub.