gpt4 book ai didi

r-markdown - 安装后尝试在 Hugo 中创建第一个网站帖子时出现 "unmarshal failed"

转载 作者:行者123 更新时间:2023-12-05 00:53:56 28 4
gpt4 key购买 nike

我按照 Hugo 的快速入门指南 (https://gohugo.io/getting-started/quick-start/) 中的说明进行操作,但在尝试创建帖子时不断收到此错误消息:

unmarshal failed: Near line 1 (last key parsed 'theme'): expected value but found '\\' instead

我在下面发布了我的一些代码行。错误消息出现在底部。谁能帮忙指出我做错了什么?

C:\Users\Scott\quickstart\MyHugoBlog\themes>git init
Initialized empty Git repository in C:/Users/Scott/quickstart/MyHugoBlog/themes/.git/

C:\Users\Scott\quickstart\MyHugoBlog\themes>git submodule add https://github.com/dashdashzako/paperback.git
Cloning into 'C:/Users/Scott/quickstart/MyHugoBlog/themes/paperback'...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 194 (delta 3), reused 9 (delta 1), pack-reused 178 eceiving objects: 53% (103/194)
Receiving objects: 100% (194/194), 466.30 KiB | 5.62 MiB/s, done.
Resolving deltas: 100% (93/93), done.
warning: LF will be replaced by CRLF in .gitmodules.
The file will have its original line endings in your working directory

C:\Users\Scott\quickstart\MyHugoBlog\themes>echo theme = \"paperback\" >> config.toml

C:\Users\Scott\quickstart\MyHugoBlog\themes>hugo new posts/my-first-post.md
Error: "C:\Users\Scott\quickstart\MyHugoBlog\themes\config.toml:1:1": unmarshal failed: Near line 1 (last key parsed 'theme'): expected value but found '\\' instead

最佳答案

您似乎正在按照适用于 Windows 上的类 Unix 系统的说明进行操作。这个命令没有做你想做的事:

echo theme = \"paperback\" >> config.toml

在 Linux 上使用 Bash,例如,此附加

theme = "paperback"

到您的 config.toml 文件,如有必要,创建它。这就是 Hugo 期望在文件中找到的内容。

但是,在 Windows 上使用 cmd.exe 我会得到反斜杠:

theme = \"paperback\"

使用 PowerShell,我得到了一些更奇怪的东西:

theme
=
\paperback\

这些看起来都不是有效的TOML对我来说,两者都包含错误消息中引用的多余反斜杠。我建议您只需使用您喜欢的文本编辑器编辑 config.toml 并添加预期的

theme = "paperback"

手动行。

关于r-markdown - 安装后尝试在 Hugo 中创建第一个网站帖子时出现 "unmarshal failed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66939869/

28 4 0