Quick answer

In a mapping, each key should appear only once at the same level.

YAML Duplicate Key

In a mapping, each key should appear only once at the same level. If the same key is repeated, parsers may error or use only the last value.

Common causes

How to fix

Examples

Bad

name: app
name: other

Good

name: app
version: other

FAQ

Can YAML have two keys with the same name?
No. At the same level, each key must be unique; the second occurrence overwrites or causes an error depending on the parser.
How do I have multiple values for one key in YAML?
Use a list as the value: key: [a, b, c] or key: with a newline and list items (e.g. - a, - b).

Fix it now

Try in validator (prefill this example)

Related

All tools · Canonical