如何让 Hugo 检测主题?
How can I let Hugo detect theme?
我正在尝试 Hugo 主题,当我使用命令 hugo server
时,我看到了以下错误消息。
Building sites … WARN 2020/07/20 14:33:07 Page.URL is deprecated and will be removed in a future release. Use .Permalink or .RelPermalink. If what you want is the front matter URL value, use .Params.url
ERROR 2020/07/20 14:33:07 render of "taxonomy" failed: "D:\Hugo\bin\my_conf\themes\devfest-theme-hugo\layouts\_default\baseof.html:7:3": execute of template failed: template: taxonomy/list.html:7:3: executing "taxonomy/list.html" at <readFile "static/icons.svg">: error calling readFile: file "static\icons.svg" does not exist
ERROR 2020/07/20 14:33:07 render of "home" failed: "D:\Hugo\bin\my_conf\themes\devfest-theme-hugo\layouts\_default\baseof.html:7:3": execute of template failed: template: index.html:7:3: executing "index.html" at <readFile "static/icons.svg">: error calling readFile: file "static\icons.svg" does not exist
Built in 100 ms
Error: Error building site: failed to render pages: render of "taxonomy" failed: "D:\Hugo\bin\my_conf\themes\devfest-theme-hugo\layouts\_default\baseof.html:7:3": execute of template failed: template: taxonomy/list.html:7:3: executing "taxonomy/list.html" at <readFile "static/icons.svg">: error calling readFile: file "static\icons.svg" does not exist
好像说我放错了一些模板文件。不知是我主题安装正确,还是我理解错了什么?
我做了什么
- 已安装
hugo
并确认已安装。
- 创建了一个名为
my-conf
的新站点(刚刚试用)和 themes
目录。
- 我已将存储库克隆到我的
themes
目录中。我在 Windows. 上使用 GitHub 桌面
- 使用
theme = "devfest-theme-hugo"
添加了主题信息。
- 使用命令
hugo server
。
理想情况下,您可以将主题添加为子模块,as in the documentation, and the theme page itself:
hugo new site my-conf
cd my-conf
mkdir themes
git submodule add https://github.com/GDGToulouse/devfest-theme-hugo.git themes/devfest-theme-hugo
并将其添加到您的配置中(您似乎已经这样做了):
echo 'theme = "ananke"' >> config.toml
To use the readFile
function in your templates, make sure the path is relative to your Hugo project’s root directory:
{{ readFile "/content/templates/local-file-templates" }}
在模板中:layouts/_default/baseof.html
似乎有正确的路径。
然而,回顾 GDGToulouse/devfest-theme-hugo/layouts/_default/baseof.html
, I see it has changed during a commit "WIP 2020" 的历史。
{{ readFile "themes/devfest-theme-hugo/static/icons.svg" | safeHTML }}
从 the discussion 开始,似乎效果更好!
我正在尝试 Hugo 主题,当我使用命令 hugo server
时,我看到了以下错误消息。
Building sites … WARN 2020/07/20 14:33:07 Page.URL is deprecated and will be removed in a future release. Use .Permalink or .RelPermalink. If what you want is the front matter URL value, use .Params.url
ERROR 2020/07/20 14:33:07 render of "taxonomy" failed: "D:\Hugo\bin\my_conf\themes\devfest-theme-hugo\layouts\_default\baseof.html:7:3": execute of template failed: template: taxonomy/list.html:7:3: executing "taxonomy/list.html" at <readFile "static/icons.svg">: error calling readFile: file "static\icons.svg" does not exist
ERROR 2020/07/20 14:33:07 render of "home" failed: "D:\Hugo\bin\my_conf\themes\devfest-theme-hugo\layouts\_default\baseof.html:7:3": execute of template failed: template: index.html:7:3: executing "index.html" at <readFile "static/icons.svg">: error calling readFile: file "static\icons.svg" does not exist
Built in 100 ms
Error: Error building site: failed to render pages: render of "taxonomy" failed: "D:\Hugo\bin\my_conf\themes\devfest-theme-hugo\layouts\_default\baseof.html:7:3": execute of template failed: template: taxonomy/list.html:7:3: executing "taxonomy/list.html" at <readFile "static/icons.svg">: error calling readFile: file "static\icons.svg" does not exist
好像说我放错了一些模板文件。不知是我主题安装正确,还是我理解错了什么?
我做了什么
- 已安装
hugo
并确认已安装。 - 创建了一个名为
my-conf
的新站点(刚刚试用)和themes
目录。 - 我已将存储库克隆到我的
themes
目录中。我在 Windows. 上使用 GitHub 桌面
- 使用
theme = "devfest-theme-hugo"
添加了主题信息。 - 使用命令
hugo server
。
理想情况下,您可以将主题添加为子模块,as in the documentation, and the theme page itself:
hugo new site my-conf
cd my-conf
mkdir themes
git submodule add https://github.com/GDGToulouse/devfest-theme-hugo.git themes/devfest-theme-hugo
并将其添加到您的配置中(您似乎已经这样做了):
echo 'theme = "ananke"' >> config.toml
To use the
readFile
function in your templates, make sure the path is relative to your Hugo project’s root directory:
{{ readFile "/content/templates/local-file-templates" }}
在模板中:layouts/_default/baseof.html
似乎有正确的路径。
然而,回顾 GDGToulouse/devfest-theme-hugo/layouts/_default/baseof.html
, I see it has changed during a commit "WIP 2020" 的历史。
{{ readFile "themes/devfest-theme-hugo/static/icons.svg" | safeHTML }}
从 the discussion 开始,似乎效果更好!