YAML by Example: Comments
1.2
Document your configuration. Add explanatory notes.
Code
# This is a full-line comment
key: value # This is an inline comment
# Comments can be indented
list:
- item1
# - item2 (commented out item)
- item3
# Block comments don't exist in YAML
# You must use a hash at the start of
# every line.Explanation
Comments in YAML start with # and continue to the end of the line. They can be on their own line or after data. Anything following the hash symbol is ignored by the parser.
YAML doesn't have block comment syntax like some languages. To comment multiple lines, put a # at the start of each line. Comments are essential for explaining configuration choices or temporarily disabling options.
Code Breakdown
1
# marks the start of a comment.
