I'm stuck!

There I get a problem:
As I want to create my first site I enter:
hugo new my_first
I get back:
Error: yaml: line 1: did not find expected key
What’s the name of the respective (config) file,
where (in what directory) can I find it, and
what (which key) do I have to insert into that line #1 ?
Thanks

Try hugo new site my_first.

2 Likes

Thank you for your help.
It worked so far … but not completely. I typed
> [~/quick] > hugo new site posts/erste
and that works. I successfully created my first site
("~/quick/posts/erste".) and got the »Congratulations!..« message.
But then I wanted to create my first page into that site
and that went wrong,
I still got the same error message. I typed:
[~/quick] > hugo new posts/erste/text_01.md
and I also tried
[~/quick] > hugo new erste/text_01.md
but I always got this error message:
» Error: yaml: line 1: did not find expected key «
And that’s where I do not know how to go on.
So I am grateful for every help.

I run the Hugo command in the folder I want to create the site for hugo new site example-site and for the post hugo new posts/post1.md inside the site itself at the root (where the config.toml file exists). Perhaps a Hugo dev can answer you better since I have not seen any command like your example in the docs.
NB: I use Git to run Hugo commands.

As I’m using Linux instead MacOS I got yaml instead of toml.
Maybe the whole problem is a special yaml issue?
Still I always get this error message:
» Error: yaml: line 1: did not find expected key «
I assume there is a file like »config.yaml«
that lacks a certain statement in line 1.
But as much I search I have not found the right file
and I have no clue what statement it needs in line 1.
Some ideas?

@Hochhaltinger

Start over, and follow these instructions:
https://gohugo.io/getting-started/quick-start/

If you continue to have problems, please post a link to the public repository for your project.

See https://discourse.gohugo.io/t/requesting-help/9132.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

1 Like

It worked so far … but not completely. I typed
> [~/quick] > hugo new site posts/erste
and that works. I successfully created my first site.

Note your site dir in: /quick/posts/erste that was the root of your site where config file and content and other directory reside.
Solution is simple then change directory (cd) to $ cd /quick/posts/erste
then hit hugo command to create content as you perform before hugo new text_01.md
now look on content directory $ ls content/ if you are on the right working directory you’ll see text_01.md

At the moment I have no source code.
After creating my first website (the directory frame)
»hugo new site …« (successful!)
I just try to create my first page in that site:
»hugo new …« (which triggered said error message
» Error: yaml: line 1: did not find expected key «.
But I’m in the right directory as typing the same in aby other directory causes an additional error message. All seems to center around the question: Where does yaml take over and where is it’s control file where I obviously have to insert that key it now reclaims missing in it’s error message?

Following that Quick Start documantary is what I do.
Creating the directory frame for my new website (point 3)
(by »hugo new site posts/[site]«) works well.
But then point 4 »hugo create new posts/[site]/myfirstpage.md«
as well as »hugo create new [site]/myfirstpage.md«
both result in no action but an error message:
» Error: yaml: line 1: did not find expected key «
So I’m asking:
In what file I will have to insert that »missing key«?

→ As you say, going down one notch:
~/quick $ cd posts

→ But this is the wrong place for that command:
~/quick/posts $ hugo new erste/text01.md

→ it only created this additional error message
→ like any other directory does, except » ~/quick «:
Error: Unable to locate Config file. Perhaps you need to create a new site.
Run hugo help new for details. (Unsupported Config Type “”)

→ so let’s go one up again:
~/quick/posts $ cd …

→ and ONLY HERE IT WORKS … as usual:
~/quick $ hugo new erste/text01.md

→ with only that very error message again
Error: yaml: line 1: did not find expected key
→ and it does NOT create any new file!

I asked you to follow the Quick Start instructions.

You chose to do something else.

I exactly followed those instructions.
only at point 4 (creating content) I got stuck with the error message I mentioned.
»Error: yaml: line 1: did not find expected key«

No, you did not.

The Quick Start instructions are:

hugo new site quickstart
cd quickstart
git init
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
echo theme = \"ananke\" >> config.toml
hugo new posts/my-first-post.md
hugo server -D

Perhaps someone else can help you.

1 Like

Okay you got me.
I had downloaded the Ananke theme (the ZIP file) already
(as proposed in another doc) and had it installed beforehand.
There I had to create the directory »quickstart«, and that installation created all lower directories I’m working on now.
And my config.toml DOES contain the line »theme = “ananke”«

You cannot ‘preinstall’ a theme before doing

hugo new site quickstart
cd quickstart

because the directory in which you would be working would not exist yet.
In addition hugo new site wants to create the directory and populate it, not work on an existing directory.

When you extract the ZIP, you should be extracting it into the quickstart directory, and then, in the quickstart directory follow the guide:

Rename that directory to “ananke”, and move it into the “themes/” directory.

Note that means:

mv gohugo-theme-ananke-master ananke
mkdir themes
mv ananke themes/

Bingo!
This is exactly what I did.

Do you mean this is what you got wrong? Or did the above, and it didn’t work?

You described exactly the way I created the directory »quickstart« and populated it with the whole environment below.
and the »hugo new site« command worked as expected, it created the new (sub-) directory tree and populated it correctly.
But the next command did not work as expected.
After creating my first website (the directory frame)
with »hugo new site …« (successful!)
I tried to create my first content page in that site:
»hugo new …«
But this only triggered the error message
» Error: yaml: line 1: did not find expected key « .
All seems to center around the one question: Where does yaml take over and where is the control file where I obviously have to insert that key it reclaims missing in it’s error message?

Wait. That’s not right. You deviated from the instructions. You need to create a site by doing:

hugo new site quickstart

and when you create new content you literally type:

hugo new posts/my-first-post.md

Do not riff until you’ve succeeded following exactly, please.

CONGRATULATIONS! That was it.
ONE BIG »THANK YOU!« TO ALL OF YOU!!!
Only creating ~/quickstart by »md« command and filling the content of the the Ananke ZIP file into that directory (as I have been told in some other doc file about how to install the Ananke theme) obviously was not good enough.