【问题标题】:Hugo is unable to find themes directoryHugo 找不到主题目录
【发布时间】:2018-10-10 21:52:29
【问题描述】:

在我的项目中,我有一个小脚本,它运行一些构建脚本来准备我的开发。但是,我当前的配置导致错误。它在错误的位置寻找主题目录。

我的构建脚本位于根目录中。我的 hugo 应用程序位于 frontend/。我想从路由调用构建脚本并让它构建hugo。

/my-project
  /frontend
    /custom-theme
  build-script.sh

我的frontend/config.toml

baseURL = "https://site.local"
title = "Site Title"
themesDir = "themes"
theme = "custom-theme"
disableKinds = [ "taxonomyTerm", "taxonomy", "robotsTXT" ]

当我使用以下命令从构建目录运行构建脚本时,出现错误:

# Build HTML and CSS
npm run build:dev --prefix $PWD/frontend/themes/custom-theme

# Hugo frontend
hugo --config $PWD/frontend/config.dev.toml

# Build PHP dependencies
composer install -d $PWD/api/

错误:

Error: Unable to find theme Directory: C:\Users\James\Projects\my-project\themes\custom-theme

它缺少路径的\frontend 部分。应该是:

C:\Users\James\Projects\my-project\frontend\themes\custom-theme

是否可以告诉hugo在哪里寻找主题?

【问题讨论】:

    标签: hugo


    【解决方案1】:

    听起来 Hugo 假设您的路径是相对于当前目录的。您是从C:\Users\James\Projects\my-project 目录构建的,因此当 Hugo 将其与您的themesDir 设置themes 放在一起时,它会得到C:\Users\James\Projects\my-project\themes。相反,请尝试设置themesDir = "frontend\themes"

    对此的一个推论是,如果您希望 Hugo 的行为与从 frontend 目录构建时一样,您还需要设置所有其他目录选项。例如,您需要设置contentDir = "frontend\content"layoutDir = "frontend\layout"。您可以在Hugo documentation 中查看哪些目录是可配置的。

    但需要注意的是:我自己并没有实际测试过,所以如果它不起作用,这可能就是原因。 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-19
      • 1970-01-01
      • 2012-08-25
      • 2020-11-10
      • 2021-05-06
      • 2020-08-16
      • 2020-05-12
      • 1970-01-01
      相关资源
      最近更新 更多