skip to Main Content

I’m getting this error when I try to create a new content in my hugo server on Ubuntu.
I have a hugo.toml config file with this content:

baseURL = 'https://mytraveltreasury/'
languageCode = 'en-us'
title = 'My Travel Treasury'
theme = 'ananke'


[params]
  commentoEnable = true
  
[languages]
  [languages.en]
    title = "My Travel Treasury"
    weight = 1
    contentDir = "content/en"
    # languageDirection = 'rtl' for Right-To-Left languages
  [languages.it]
    title = "My Travel Treasury IT"
    weight = 2
    contentDir = "content/it"
  [languages.es]
    title = "My Travel Treasury ES"
    weight = 3
    contentDir = "content/es"    
[[params.ananke_socials]]
name = "twitter"
url = "https://twitter.com/GoHugoIO"   

and I created an additional config.toml in the root directory with just one single line:

contentDir = "content"

In my root directory I have a folder called content and I created manually a new file colled index.md.

I have booted my hugo server with hugo server and Ctl+c and tried to create a new file for my blog content with this command hugo new content content/first.md, but I got this error: Error: no existing content directory configured for this project

Any ideas for fixing this?

2

Answers


  1. Chosen as BEST ANSWER

    As it was mentioned, there's no need to configure an additional file and configuration should be defined on hugo.toml.

    The issue was as described in the question that I was defining several contentDir for the addtional languages. That was causing the system to not be able to define where and raising the error that contentDis wasn't defined.

    I removed the three locations and added the one from my config.toml, removed config.toml and reboot the server.

    And voila!, it's working again.


  2. The config file should be called hugo.toml not config.toml. See the documentation here.
    Either rename it, or run hugo using the --config parameter:
    hugo --config config.toml

    Other parts of Hugo are configured using config.toml, such as inside themes, which might be where the confusion comes from.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search