How to escape a colon in Front matter YAML?

In the front matter of your Jekyll posts, you might want to include a colon. However, if you don’t escape it, you will get an “Error: YAML Exception reading …” error.

There are 3 ways to escape the colon in the Front matter of your posts.

  1. Put the text around quotes.

    Wrong

     title: How to escape colon: in Front matter YAML
    

    Correct

     title: "How to escape colon: in Front matter YAML"
    
  2. Replace the colon with :

     title: "How to escape colon: in Front matter YAML"
    

    The Jekyll YAML parser will replace it will the :

  3. Use a greater than sign (>) and put the text indented and in a new line.

     title: >
         How to escape: colon in Front matter YAML?
    

Personally, whenever I need to escape the colon (:), I just put the value around quotes.

Want to learn how to code and make money online? Check out CodingPhase (referral link)