安装后尝试在 Hugo 中创建第一个网站帖子时出现“unmarshal failed”

Sco*_*uda 3 markdown r-markdown hugo

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

unmarshal failed: Near line 1 (last key parsed 'theme'): expected value but found '\\' instead
Run Code Online (Sandbox Code Playgroud)

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

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
Run Code Online (Sandbox Code Playgroud)

Chr*_*ris 9

看起来您正在遵循适用于 Windows 上的类 Unix 系统的说明。该命令没有执行您想要的操作:

echo theme = \"paperback\" >> config.toml
Run Code Online (Sandbox Code Playgroud)

例如,在 Linux 上使用 Bash,这会附加

theme = "paperback"
Run Code Online (Sandbox Code Playgroud)

到您的config.toml文件,必要时创建它。这就是雨果希望在文件中找到的内容。

但是,cmd.exe在 Windows 上使用时,我得到了包含反斜杠的信息:

theme = \"paperback\"
Run Code Online (Sandbox Code Playgroud)

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

theme
=
\paperback\
Run Code Online (Sandbox Code Playgroud)

对我来说,这两个看起来都不像有效的TOML,并且都包含错误消息中引用的无关反斜杠。我建议您只需config.toml使用您最喜欢的文本编辑器进行编辑并添加预期的

theme = "paperback"
Run Code Online (Sandbox Code Playgroud)

手动线路。