📌 Improve your Angular CLI skills with this free Angular CLI course on Pluralsight

TL;DR

Make sure to escape any double quotes that you have in a field in the front matter of your hugo content files. You can escape double quotes with a backslash.

Backstory

I was trying to add a new "description" field to the front matter of one of my blog posts in Hugo and I was met with this error: failed to unmarshal YAML: yaml: line 1: did not find expected key

Double quotes within a double quotes wrapped string will throw this error:

Hugo Error Message

ERROR:
Change of config file detected, rebuilding site.
2021-01-18 13:14:12.372 -0600
ERROR 2021/01/18 13:14:12 "C:\repos\BrendanSlukeCom\content\blog\solution-ngps1-cannot-be-loaded-angular-and-nodejs-error.md:2:1": failed to unmarshal YAML: yaml: line 1: did not find expected key

This error message tells us that something is wrong with the front matter in our markdown file, in my case the front matter for my blog post looked like this:

---
title: "Solution: ng.ps1 cannot be loaded, The file is not digitally signed."
description: "How to resolve "ng.ps1 cannot be loaded, the file is not digitally signed" when attempting to run commands "ng serve" or "ng new" in a Visual Studio Code terminal for an Angular project setup."
date: 2021-01-18T13:07:41-06:00
draft: false
---
<!-- Rest of markdown below here -->

Solution - How to Escape Double Quotes in Front Matter for Hugo?

The issue here was the Double Quotes within the the value of the key/value pair in the front matter. The double quotes need to be escaped.

My original description front matter was:

description: "How to resolve "ng.ps1 cannot be loaded, the file is not digitally signed" when attempting to run commands "ng serve" or "ng new" in a Visual Studio Code terminal for an Angular project setup."

But with escaped double quotes, the description front matter looks like this:

description: "How to resolve \"ng.ps1 cannot be loaded, the file is not digitally signed\" when attempting to run commands \"ng serve\" or \"ng new\" in a Visual Studio Code terminal for an Angular project setup."
📌 Improve your Angular CLI skills with this free Angular CLI course on Pluralsight
Related Blog Posts