2

I have a .yaml file like this:

title: 'We'll do cool stuff'
draft: true

However, I get the following error:

Error parsing YAML: YAMLException: can not read a block mapping entry; 
a multiline key may not be an implicit key at line 2, column 6:

  draft: true
       ^

How can I fix it?

Note: this setup seems different than the other questions where this same error was raised, including the following posts:

KyleMit
  • 30,350
  • 66
  • 462
  • 664

2 Answers2

5

You can use a site like YAML Formatter to format and validate your yaml:

yaml formatter example

In this case, the error message and location is a bit of red-herring.

The error is actually caused by a string that was accidentally terminated because of an unescaped quote symbol within the string. A hint for this is the syntax highlighting of 'We'll do cool stuff'.

To fix, in this case, you can just skip wrapping the string quotes and rewrite like this:

title: We'll do cool stuff
draft: true

Further Reading

KyleMit
  • 30,350
  • 66
  • 462
  • 664
1
title: "We'll do cool stuff"
draft: true

I have got the exact same issue, The problem with it is, we are using a single quote' in between the string and also wrapping the string with a single quote. I resolved it by wrapping the string with a double quote.

You can also trace the issue more by reading this