Scott Freuda
Scott Freuda

Reputation: 47

Getting "unmarshal failed" when trying to create first website post in Hugo after installation

I'm following the instructions at Hugo's Quickstart guide (https://gohugo.io/getting-started/quick-start/) but I keep getting this error message when I try to create a post:

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

I've posted some lines of my code below. The error message appears at the bottom. Could anyone help point out what I am doing wrong?

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

Upvotes: 4

Views: 9060

Answers (2)

Gregory
Gregory

Reputation: 7232

The issue on my end was that the file wasn't created as UTF-8 Delete the config.toml file and recreate it manually on your text editor, then paste the content like: theme = "ananke" should work

Upvotes: 1

Chris
Chris

Reputation: 136936

It looks like you're following instructions meant for Unix-like systems on Windows. This command isn't doing what you want:

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

Using Bash on Linux, for example, this appends

theme = "paperback"

to your config.toml file, creating it if necessary. That's what Hugo expects to find in the file.

However, using cmd.exe on Windows I get the backslashes included:

theme = \"paperback\"

And using PowerShell, I get something even stranger:

theme
=
\paperback\

Neither of these looks like valid TOML to me, and both contain extraneous backslashes as referenced in your error message. I suggest you simply edit config.toml using your favourite text editor and add the expected

theme = "paperback"

line manually.

Upvotes: 10

Related Questions