Hugo Error: No existing content directory is configured for this project

王林
Release: 2024-02-09 18:20:08
forward
577 people have browsed it

Hugo 错误:没有为此项目配置现有内容目录

php Editor Strawberry encountered a common error when using the Hugo static website generator: "Hugo Error: No existing content directory is configured for this project." This error message means that Hugo cannot find the specified content directory, resulting in the failure to generate the website. To solve this problem, we need to check that the content directory is set correctly in the Hugo configuration file and ensure that the directory exists in the project. By solving this problem, we can smoothly generate static websites and carry out subsequent development and deployment work.

Question Content

I get this error when I try to create new content in a Hugo server on Ubuntu. I have a hugo.toml configuration file with the following 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"
Copy after login

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

contentDir = "content"
Copy after login

In my root directory, there is a folder named content and I manually created a new file colled index.md.

I have started my hugo server using hugo server and Ctl c and I am trying to create a new file for my blog content using this command hugo new content content/first.md but I am getting this error: Error: There is no existing content for the directory configured for this project

Any ideas to solve this problem?

Solution

As mentioned earlier, no additional files are required to configure, the configuration should be defined on hugo.toml.

Problem As mentioned in the question, I am defining multiple contentDir for other languages. This results in the system being unable to define the location and throwing a contentDis undefined error.

I removed the three locations and added one location from my config.toml, deleted the config.toml and restarted the server.

Look! It started working again.

The above is the detailed content of Hugo Error: No existing content directory is configured for this project. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!