我按照 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/
我想在我的博客主页上添加一张 map 。它需要接受一些参数。我正在努力弄清楚如何正确配置它。我通过对设置进行硬编码来让它工作,但这并不适合与其他人分享我的解决方案。 我的问题是我将它实现为部分:{{
我正在为一位设计师在 Hugo 中构建一个网站。它包括一个投资组合,每篇文章中都有图片。 我认为最简单的管理方法是使用页面包。也就是说,在每个帖子的文件夹中包含图像,并让 Hugo 自动将该页面包中的
如何注释掉 Hugo 中的内容? 如果我有笔记,未完成的想法,我想把它们留在.md文件但没有它们出现在 html 中.