Matthew Andrews
Product Manager ・ Software Engineer ・ Executive MBA Graduate ・ Tokyo Resident

How to write a hash in YAML

I was tripped up by this silly little thing whilst writing a blog post with the title Week Notes #1 - Copying, Listening, Running, Emergency, which rendered as simply “Week Notes” — losing everything from the ‘#’ onwards.

My code was:

1
title: Week Notes #1 - Copying, Listening, Running, Emergency

YAML had, as my blog’s syntax highlighting hints, interpretted everything from the # (hash or pound) symbol onwards as a comment.

The fix is simple. Put the #-containing content in quotes:

1
title: 'Week Notes #1 - Copying, Listening, Running, Emergency'