#Frontmatter quotation marks

3 messages · Page 1 of 1 (latest)

arctic hill
#

Does it matter if I use single or double quotation marks in frontmatter or do I even need them at all?

ebon plumeBOT
#

Hi @arctic hill. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Astro uses the YAML syntax in the frontmatter. In YAML, both single and double quotation marks can be used to denote string values. However, there are some differences in how they handle escape sequences and special characters.

Double quotes(") interpret escape sequences, while single quotes(') do not. For example, in double quotes, \n would be interpreted as a newline character, while in single quotes, it would be interpreted as the literal characters \ and n.

In some cases, you might not need quotation marks at all. For instance, if your value is a simple alphanumeric string without any special characters, you can usually omit the quotation marks.

However, there was a discussion (https://github.com/withastro/astro/issues/8374) on GitHub where a user had an issue with escaping an apostrophe in frontmatter. The solution was to remove the surrounding single quotes.

So, while both single and double quotes can be used in YAML frontmatter, the way they handle content is different, and in some cases, you might not need them at all. Always consider the content you're working with when deciding whether to use quotes and what type to use.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: