Anchors (&
) and aliases (*
) let you define a value once and reuse it anywhere in your YAML file. Theyβre insanely useful for keeping big configs DRY (Donβt Repeat Yourself).
title: &title "Dashboard"
then reuse with main_title: *title
.
&
creates an anchor (like a reusable template)*
references (aliases) the anchor wherever needed&&
optional, but you can merge whole mappings with &&defaults
or &defaults
<<: *anchor
merges the whole block at that pointBoth home_msg
and about_msg
would get Hello, YAML World!
.