How to escape indicator characters (i.e. : or – ) in YAML

delimiterescapingyaml

In a config file, I have a key to which I wish to assign a URL. The problem is that YAML interprets : and – characters as either creating mappings or lists, so it has a problem with the line

url: http://www.example-site.com/

(both because of the colon following http and the hyphen in the middle)

Is there an explicit way to escape ':' and '-' ? Or would it work to just put the whole thing in single quotes and call it a day?

Best Answer

Quotes:

"url: http://www.example-site.com/"

To clarify, I meant “quote the value” and originally thought the entire thing was the value. If http://www.example-site.com/ is the value, just quote it like so:

url: "http://www.example-site.com/"